Bug #55602 select count(*) + order by desc + limit + partitioning delivers not all results
Submitted: 28 Jul 2010 13:35 Modified: 28 Aug 2010 13:59
Reporter: Rene Eng Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.1.46 OS:Solaris (10, 64 bit)
Assigned to: CPU Architecture:Any

[28 Jul 2010 13:35] Rene Eng
Description:
The following query returns ~ 12000 results on my partitioned table:
select count(*), field1, field2 from MyTable where field3 = 88 group by 2, 3 order by 1 desc;
--> 12003 rows in set (1.00 sec)

The same query with limit returns only 1 result!
select count(*), field1, field2 from MyTable where field3 = 88 group by 2, 3 order by 1 desc limit [2..62];
--> 1 row in set (0.13 sec)

The same result is returned for all limits in the range 2 .. 62. With a limit >= 63, the result is correct:
--> 63 rows in set (0.93 sec)

The result is also correct if the 'order by' clause is omitted:
select count(*), field1, field2 from MyTable where field3 = 88 group by 2, 3 limit 20;
--> 20 rows in set (0.23 sec)

On a non-partitioned table the requests work all okay.

How to repeat:
Create a partitioned table, insert data and try the requests as described.

Suggested fix:
Always return the correct (maximum) number of results.
[28 Jul 2010 13:59] Valeriy Kravchuk
Please, check if the same problem happens with current version, 5.1.49. Send dump of the table in case of the same bug with 5.1.49.
[28 Aug 2010 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".