My database have 10.000.000 record
I want select from database but it is heavy
Query i have tried:
SELECT * FROM `table` USE INDEX (id) JOIN `new` AS p1
USE INDEX (pid) ON table.id = p1.pid
WHERE `p1.date` > '2015-02-01' AND `p1.date` < '2016-02-01'
You need an index on columns new.date
and table.id
.
You probably don't need the USE INDEX hints.
I am assuming that there not too many rows in the date range. If a large proportion of your rows are in that range, obviously, it will take a long time.