Index: wp-admin/includes/upgrade.php
===================================================================
--- wp-admin/includes/upgrade.php	(revision 11075)
+++ wp-admin/includes/upgrade.php	(working copy)
@@ -654,22 +654,23 @@
 
 	if ( $wp_current_db_version < 3506 ) {
 		// Update status and type.
-		$posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
-
-		if ( ! empty($posts) ) foreach ($posts as $post) {
-			$status = $post->post_status;
-			$type = 'post';
-
-			if ( 'static' == $status ) {
-				$status = 'publish';
-				$type = 'page';
-			} else if ( 'attachment' == $status ) {
-				$status = 'inherit';
-				$type = 'attachment';
-			}
-
-			$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID) );
-		}
+		$wpdb->query("
+			UPDATE	$wpdb->posts
+			SET		post_type = CASE
+					WHEN post_status = 'page'
+					THEN 'page'
+					WHEN post_status = 'attachment'
+					THEN 'attachment'
+					ELSE 'post'
+					END,
+					post_status = CASE
+					WHEN post_status = 'page'
+					THEN 'publish'
+					WHEN post_status = 'attachment'
+					THEN 'inherit'
+					ELSE post_status
+					END;
+			");
 	}
 
 	if ( $wp_current_db_version < 3845 ) {
