Index: post.php
===================================================================
--- post.php	(revision 18864)
+++ post.php	(working copy)
@@ -3379,31 +3379,21 @@
 		$hierarchical = false;
 		$incpages = wp_parse_id_list( $include );
 		if ( ! empty( $incpages ) ) {
-			foreach ( $incpages as $incpage ) {
-				if (empty($inclusions))
-					$inclusions = $wpdb->prepare(' AND ( ID = %d ', $incpage);
-				else
-					$inclusions .= $wpdb->prepare(' OR ID = %d ', $incpage);
-			}
+			// We have ints here as wp_parse_id_list() made sure of that.
+			// So we just combine them in a subset and avoid the extra ->prepare().
+			// And we also shorten the query ALOT ;) (alots rule)
+			$inclusions = ' AND ID IN ('.implode(', ', $incpages).')';
 		}
 	}
-	if (!empty($inclusions))
-		$inclusions .= ')';
 
 	$exclusions = '';
 	if ( !empty($exclude) ) {
 		$expages = wp_parse_id_list( $exclude );
 		if ( ! empty( $expages ) ) {
-			foreach ( $expages as $expage ) {
-				if (empty($exclusions))
-					$exclusions = $wpdb->prepare(' AND ( ID <> %d ', $expage);
-				else
-					$exclusions .= $wpdb->prepare(' AND ID <> %d ', $expage);
-			}
+			// Same optimization as with $inclusions
+			$exclusions = ' AND ID NOT IN ('.implode(', ', $expages).')';
 		}
 	}
-	if (!empty($exclusions))
-		$exclusions .= ')';
 
 	$author_query = '';
 	if (!empty($authors)) {
