| Bug #32198 | Comparison of DATE with DATETIME still not using indexes correctly | ||
|---|---|---|---|
| Submitted: | 8 Nov 2007 22:03 | Modified: | 19 Dec 2007 6:19 |
| Reporter: | Dave Costantino | ||
| Status: | Closed | ||
| Category: | Server: Types | Severity: | S2 (Serious) |
| Version: | 5.0.50, 5.0.52-BK | OS: | Linux |
| Assigned to: | Sergey Petrunia | Target Version: | |
| Tags: | regression | ||
| Triage: | D2 (Serious) | ||
[8 Nov 2007 22:03]
Dave Costantino
[11 Nov 2007 12:58]
Valeriy Kravchuk
Thank you for a problem report. Verified just as described with latest 5.0.52-BK. I think, it is a bug, as this page, http://dev.mysql.com/doc/refman/5.0/en/type-conversion.html, does NOT say anything specific about DATETIME to DATE conversion. This: "If one of the arguments is a TIMESTAMP or DATETIME column and the other argument is a constant, the constant is converted to a timestamp before the comparison is performed." does NOT apply, as we have a DATE column that is compared to DATETIME constant. So, constant should be converted to column's type, and then index will be used.
[13 Nov 2007 5:53]
Valeriy Kravchuk
Bug #32002 was marked as a duplicate of this one.
[12 Dec 2007 15:37]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/39782 ChangeSet@1.2595, 2007-12-12 17:35:52+03:00, sergefp@mysql.com +4 -0 BUG#32198: Comparison of DATE with DATETIME still not using indexes correctly - Make conditions like "date_col $CMP$ 'datetime-const'" range-sargable
[13 Dec 2007 11:39]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/39880 ChangeSet@1.2595, 2007-12-13 13:38:22+03:00, sergefp@mysql.com +4 -0 BUG#32198: Comparison of DATE with DATETIME still not using indexes correctly - Make conditions like "date_col $CMP$ 'datetime-const'" range-sargable
[14 Dec 2007 9:14]
Bugs System
Pushed into 5.0.54
[14 Dec 2007 9:17]
Bugs System
Pushed into 5.1.23-rc
[14 Dec 2007 9:20]
Bugs System
Pushed into 6.0.5-alpha
[19 Dec 2007 6:19]
Paul DuBois
Noted in 5.0.54, 5.1.23, 6.0.5 changelogs. For comparisons of the form date_col OP datetime_const (where OP is =, <, >, <=, or >=), the comparison is done using DATETIME values, per the fix for Bug#27590. However that fix caused any index on date_col not to be used and compromised performance. Now the index is used again.
