Index: trunk/pstamp/scripts/pstamp_finish.pl
===================================================================
--- trunk/pstamp/scripts/pstamp_finish.pl	(revision 24940)
+++ trunk/pstamp/scripts/pstamp_finish.pl	(revision 24941)
@@ -173,4 +173,6 @@
     }
 
+    my $exp_info;
+    my $last_exp_id = 0;
     foreach my $job (@jobs) {
         my $job_id = $job->{job_id};
@@ -181,10 +183,19 @@
 
         my ($row, $req_info, $project) = get_request_info($rows, $rownum);
-        my $proj_hash = resolve_project($ipprc, $project, $dbname);
-        my $image_db = $proj_hash->{dbname};
-
-        # get the metadata for the exposure (if any i.e. stack) 
-        # returns an appropriate string if !$exp_id
-        my $exp_info = get_exposure_info($image_db, $exp_id);
+
+        if ($exp_id ne $last_exp_id) {
+            my $proj_hash = resolve_project($ipprc, $project, $dbname, $dbserver);
+            my $image_db = $proj_hash->{dbname};
+            if (!$image_db) {
+                carp("failed to find imagedb for project: $project");
+                stop_request($req_id, $PS_EXIT_CONFIG_ERROR);
+            }
+
+            # get the metadata for the exposure (if any i.e. stack) 
+            # returns an appropriate string if !$exp_id
+            $exp_info = get_exposure_info($image_db, $exp_id);
+ # XXX: uncomment this and test
+ #           $last_exp_id = $exp_id;
+        }
 
         if (($job_type eq "stamp") || ($job_type eq "get_image")) {
