Index: wp-includes/query.php
===================================================================
--- wp-includes/query.php	(revision 17796)
+++ wp-includes/query.php	(working copy)
@@ -2586,15 +2586,11 @@
 		}
 
 		if ( ! empty($groupby) )
-			$groupby = 'GROUP BY ' . $groupby;
+			$thegroupby = 'GROUP BY ' . $groupby;
 		if ( !empty( $orderby ) )
 			$orderby = 'ORDER BY ' . $orderby;
 
-		$found_rows = '';
-		if ( !$q['no_found_rows'] && !empty($limits) )
-			$found_rows = 'SQL_CALC_FOUND_ROWS';
-
-		$this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
+		$this->request = " SELECT $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $thegroupby $orderby $limits";
 		if ( !$q['suppress_filters'] )
 			$this->request = apply_filters_ref_array('posts_request', array( $this->request, &$this ) );
 
@@ -2634,7 +2630,11 @@
 		}
 
 		if ( !$q['no_found_rows'] && !empty($limits) ) {
-			$found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) );
+			if( !empty($groupby) ) {
+				$found_posts_query = apply_filters_ref_array( 'found_posts_query', array( " SELECT COUNT(distinct $groupby) FROM $wpdb->posts $join WHERE 1=1 $where $orderby", &$this ) );
+			} else {
+				$found_posts_query = apply_filters_ref_array( 'found_posts_query', array( " SELECT COUNT(*) FROM $wpdb->posts $join WHERE 1=1 $where $orderby", &$this ) );
+			}
 			$this->found_posts = $wpdb->get_var( $found_posts_query );
 			$this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) );
 			$this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']);
