Bug #60735 | Changed behavior in optimizing SQL using view from v5.0.27 to 5.1.41 | ||
---|---|---|---|
Submitted: | 2 Apr 2011 22:59 | Modified: | 3 Apr 2011 13:49 |
Reporter: | Jacob Keane | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
Version: | 5.1.41 | OS: | Linux (Ubuntu) |
Assigned to: | CPU Architecture: | Any |
[2 Apr 2011 22:59]
Jacob Keane
[3 Apr 2011 8:43]
Valeriy Kravchuk
This is NOT a bug formally. MySQL server is free to use any value from column in the group if they are different. Read http://dev.mysql.com/doc/refman/5.1/en/group-by-hidden-columns.html: "When using this feature, all rows in each group should have the same values for the columns that are ommitted from the GROUP BY part. The server is free to return any value from the group, so the results are indeterminate unless all values are the same."
[3 Apr 2011 13:49]
Jacob Keane
Thanks for the explanation. Is there a way to pass some planner or optimizer type directive to guide the determinism towards a certain outcome? I have a work around for this already though. The query is (in case someone else needs a solution) select * from tablist where ts=(select max(ts) from tablist as intab where tablist.orderid = intab.orderid) ;