Index: wp-admin/upload.php
===================================================================
--- wp-admin/upload.php	(revision 12659)
+++ wp-admin/upload.php	(working copy)
@@ -20,8 +20,7 @@
 	if ( !current_user_can('edit_posts') )
 		wp_die( __('You are not allowed to scan for lost attachments.') );
 
-	$all_posts = implode(',', $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type IN ('post', 'page')"));
-	$lost = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent > '0' and post_parent NOT IN ($all_posts)");
+	$lost = $wpdb->get_col("SELECT att.ID FROM $wpdb->posts as att LEFT JOIN $wpdb->posts as post ON att.post_parent = post.ID WHERE att.post_type = 'attachment' and post.ID IS NULL");
 
 	$_GET['detached'] = 1;
 
