How to execute my query fast..When A date filter is there in a query it takes more time for execution.?
2 Answer(s)      4 years and a month ago
Posted in : Vurduk mu Şamarı Oynar Gotünün Damar

When A date filter is there in a query it runs for 10 mins with 4000 records.. when the date filter is commented it runs in 30 seconds with 5000 records... what is the problem ... how to execute my query fast... please help...


View Answers

February 10, 2013 at 8:27 AM


Add index on the date field.

You can use the following sql:

ALTER TABLE mytable ADD INDEX (mydatefield);


February 11, 2013 at 3:13 PM

i have already created index... but the problem is....

query is-- select * from 1stTable as ai join 2ndTable as reg on ai.coloumn=reg.coloumn and ai.mode=3 and ai.year=2013 and ai.groupidcoloumnIN ( 1, 12, 13, 17 ) AND reg.mode=3 AND ai.applnissueddate BETWEEN '2013-01-18' AND '2013-01-22'

This Query is getting late when i put 19 and other following dates . but before 18 the query runs in 6 secs when i put 19and follow it runs for 10 mins....