Index: /trunk/Nebulous-Server/Changes
===================================================================
--- /trunk/Nebulous-Server/Changes	(revision 20029)
+++ /trunk/Nebulous-Server/Changes	(revision 20030)
@@ -23,4 +23,6 @@
       level locks being set by a cursor
     - drop instance.sha1sum and instance.assigned_vol_id
+    - change find_objects_with_unavailable_instances query to work on a
+      temporary table instead of directly on the mountedvol table
 
 0.15 Thu Sep 11 13:00:59 HST 2008
Index: /trunk/Nebulous-Server/bin/neb-admin
===================================================================
--- /trunk/Nebulous-Server/bin/neb-admin	(revision 20029)
+++ /trunk/Nebulous-Server/bin/neb-admin	(revision 20030)
@@ -3,5 +3,5 @@
 # Copyright (C) 2005-2008  Joshua Hoblitt
 #
-# $Id: neb-admin,v 1.9 2008-09-30 21:55:44 jhoblitt Exp $
+# $Id: neb-admin,v 1.10 2008-10-09 23:27:44 jhoblitt Exp $
 
 use strict;
@@ -70,7 +70,19 @@
 
 # so_id, ext_id, instances, available_instances, need_recovery, recoverable
+{
+    my $query = $dbh->prepare("CREATE TEMPORARY TABLE mymountedvol LIKE mountedvol");
+    $query->execute;
+}
+
+{
+    my $query = $dbh->prepare("INSERT INTO mymountedvol SELECT * FROM mountedvol");
+    $query->execute;
+}
+
 my $query = $dbh->prepare( $sql->find_objects_with_unavailable_instances
         . " LIMIT $limit" );
 $query->execute;
+
+$dbh->do("DROP TABLE IF EXISTS mymountedvol");
 
 my @rows;
Index: /trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm
===================================================================
--- /trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm	(revision 20029)
+++ /trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm	(revision 20030)
@@ -1,5 +1,5 @@
 # Copyright (c) 2004  Joshua Hoblitt
 #
-# $Id: SQL.pm,v 1.70 2008-10-09 21:30:10 jhoblitt Exp $
+# $Id: SQL.pm,v 1.71 2008-10-09 23:27:44 jhoblitt Exp $
 
 package Nebulous::Server::SQL;
@@ -293,6 +293,6 @@
             volume.name as volume_name,
             volume.host as volume_host,
-            count(mountedvol.vol_id) as available_instances,
-            count(mountedvol.vol_id) > 0 as recoverable,
+            count(mymountedvol.vol_id) as available_instances,
+            count(mymountedvol.vol_id) > 0 as recoverable,
             storage_object_xattr.value as copies
         FROM storage_object
@@ -303,7 +303,7 @@
         LEFT JOIN storage_object_xattr
             ON storage_object.so_id = storage_object_xattr.so_id
-        JOIN mountedvol
+        JOIN mymountedvol
             USING(vol_id)
-        WHERE mountedvol.available = 1
+        WHERE mymountedvol.available = 1
 --        WHERE storage_object_xattr.name = 'user.copies'
         GROUP BY so_id
