Bug #53137 | Optimizer may be confused by an index | ||
---|---|---|---|
Submitted: | 24 Apr 2010 0:14 | Modified: | 10 Jan 2013 12:43 |
Reporter: | Mikhail T | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
Version: | 5.0.90, 4.1, 5.0, 5.1, 5.6.99 | OS: | Any (FreeBSD 7.3/amd64, Linux) |
Assigned to: | CPU Architecture: | Any |
[24 Apr 2010 0:14]
Mikhail T
[24 Apr 2010 6:36]
Sveta Smirnova
Thank you for the report. > The full dump of the table can be provided upon request. Please provide full dump.
[25 Apr 2010 18:13]
Mikhail T
Reproduce the problem described in bug 53137
Attachment: t.sql (application/octet-stream, text), 474 bytes.
[25 Apr 2010 18:14]
Mikhail T
The subset of rows and columns reproducing the bug 53137
Attachment: pc3_posts.sql (application/octet-stream, text), 3.27 KiB.
[25 Apr 2010 18:16]
Mikhail T
Ok, I was able to reduce the test case to a much smaller column- and row-counts. See the already attached t.sql and pc3_posts.sql. The two queries inside t.sql are supposed to provide the same rows in different order. Instead, the second one of them returns an empty set... In the process of doing that, I also found, that the results seem to depend on what else I was doing in my mysql-client session. There is definitely a problem, but it is not really with the LIMIT-clause itself... There are various strange discrepancies in the output, and they all seem triggered by the following index: UNIQUE KEY `topicids` (`topic_id`,`post_id`) If this index is dropped, the bug is no more...
[26 Apr 2010 5:54]
Sveta Smirnova
Thank you for the feedback. Verified as described.
[26 Apr 2010 11:40]
Mikhail T
Thank you, Светлана.
[10 Jan 2013 12:43]
Erlend Dahl
The query stated in the bugpage is not legal if we enable 'ONLY_FULL_GROUP_BY' sql mode. It is expected that the result set can vary in cases where "ONLY_FULL_GROUP_BY" is not enabled and the query is executed. This is what we have in manual. "In standard SQL, a query that includes a GROUP BY clause cannot refer to nonaggregated columns in the HAVING clause that are not named in the GROUP BY clause. A MySQL extension permits references to such columns to simplify calculations. This extension assumes that the nongrouped columns will have the same group-wise values. Otherwise, the result is indeterminate." Hence closing it as not a bug