MySQL Forums
Forum List  »  Performance

Index and date functions
Posted by: Aurelien PANIZZA
Date: January 30, 2013 10:30AM

Hi,

I'm using MySQL 5.0.96 and I try to use an index defined on a date type column with a date function. Below is a example of what my query looks like :

SELECT * FROM my_table WHERE date_col > sysdate() - INTERVAL 30 DAYS;

date_col is defined as "date" type.
I want to retrieve all rows which have a date_col not older than 30 days from the current date.

My problem is that I can't have the query use the index defined on the column date_col. The query always do a full scan on the table. Is there any way to have the query use the index when using a date function ?

regards



Edited 1 time(s). Last edit at 01/30/2013 11:28AM by Aurelien PANIZZA.

Options: ReplyQuote


Subject
Views
Written By
Posted
Index and date functions
3289
January 30, 2013 10:30AM
1411
January 31, 2013 10:22PM
1361
February 04, 2013 03:33AM
1164
February 04, 2013 10:45AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.