Monday, 3 September 2018
Subscribe to:
Post Comments (Atom)
DATE
columns that are used to specify a start and end date range. I have a single index for the two columns but it doesn't get used and the query takes 10 seconds to run which is completely unacceptable. My query is simple:SELECT * FROM `events` WHERE `valid_from` <= "2013-05-05" AND `valid_to` >= "2013-05-05"
EXPLAIN
for the query above:+----------------------------------------------------------------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----------------------------------------------------------------------------------------------------+
| 1 | SIMPLE | events | ALL | valid_from_to | NULL | NULL | NULL | 2166894 | Using where|
+----------------------------------------------------------------------------------------------------+
EXPLAIN SELECT * FROM `events` WHERE `valid_from` <= "2013-05-05" AND `valid_to` >= "2013-05-05"
SELECT * FROM `events` USE INDEX (`valid_from_to`)
WHERE `valid_from` <= "2013-05-05" AND `valid_to` >= "2013-05-05"
Hello Friends! I am Ramana a part time blogger from Hyderabad.
0 comments:
Post a Comment