How To get the Number of rows scan less when we take difference between the dates
mysql> explain SELECT now(),g.gallery_created,g.id as gallery_ids FROM gallery_event g LEFT JOIN tag m on g.id=m.gallery_id WHERE date(now())-date(g.gallery_created) <= 7;
+----+-------------+-------+--------+---------------+---------+---------+---------------------+--------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+--------+---------------+---------+---------+---------------------+--------+-------------+
| 1 | SIMPLE | g | ALL | NULL | NULL | NULL | NULL | 136193 | Using where |
| 1 | SIMPLE | m | eq_ref | PRIMARY | PRIMARY | 8 | prod.g.id | 1 | Using index |
+----+-------------+-------+--------+---------------+---------+---------+---------------------+--------+-------------+
2 rows in set (0.00 sec)
there are 136193 number of rows are there so it scann all the rows while i need data for last 7 days.. ?
Subject
Views
Written By
Posted
How To get the Number of rows scan less when we take difference between the dates
7793
September 30, 2009 11:32PM
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.