[MDEV-8937] Optimize date functions in the parser Created: 2015-10-13  Updated: 2016-01-22  Resolved: 2016-01-22

Status: Closed
Project: MariaDB Server
Component/s: Parser
Fix Version/s: N/A

Type: Task Priority: Major
Reporter: Michaël de groot Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MDEV-8320 Allow index usage for DATE(datetime_c... Closed

 Description   

Hi everybody,

I have spent many hours rewriting queries that use date functions in there where clause. They can quite easily be rewritten but I've also worked with 3rd party closed source tools that couldn't easily change their query structure.

Example: SELECT * FROM payments WHERE YEAR(creationDate) = 2015 AND MONTH(creationDate) = 9 AND method='creditcard'
This can be rewritten to: SELECT * FROM payments WHERE creationDate BETWEEN "2015/09/01 0:00:00" AND "2015/10/01 0:00:00" AND method='creditcard'

Currently, only the 'creditcard' part of a creditcard_creationDate compound index. After rewriting, the full index can be used. If creditcard payments represent 90% of the payments it would basically be a full table scan.

Thank you,
Michael



 Comments   
Comment by Michaël de groot [ 2016-01-22 ]

Duplicate to this other issue. Closing this one.

Generated at Thu Feb 08 07:30:54 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.