MySQL Forums
Forum List  »  Optimizer & Parser

Too many rows being read
Posted by: preston
Date: August 02, 2006 02:02PM

I've researched this as much as I know how and haven't come up with a solution. When I run this query it is scanning too many rows. Can someone explain why? The record that gets returned would be the 79th record found based on the parameters in the query. Why is it having to read over 1,000,000 rows?

I've included the "explain" on the query and the actual result.

Thanks.

mysql> explain select sql_no_cache id,date from inquiry use index(merchant_id, date) where date >= '2006-03-22
09:00:00' and merchant_id = 848 limit 1;
+----+-------------+---------+------+------------------+-------------+---------+-------+---------+------------
-+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra
|
+----+-------------+---------+------+------------------+-------------+---------+-------+---------+------------
-+
| 1 | SIMPLE | inquiry | ref | MERCHANT_ID,DATE | MERCHANT_ID | 4 | const | 1066484 | Using where
|
+----+-------------+---------+------+------------------+-------------+---------+-------+---------+------------
-+
1 row in set (0.08 sec)

mysql> select sql_no_cache id,date from inquiry use index(merchant_id, date) where date >= '2006-03-22 09:00:0
0' and merchant_id = 848 limit 1;
+---------+---------------------+
| id | date |
+---------+---------------------+
| 5580925 | 2006-03-22 09:00:06 |
+---------+---------------------+
1 row in set (10.61 sec)

Options: ReplyQuote


Subject
Views
Written By
Posted
Too many rows being read
2892
August 02, 2006 02:02PM
1729
August 02, 2006 02:18PM


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.