MySQL Forums
Forum List  »  Optimizer & Parser

Re: MYSQL optimizer: Handling Subqueires
Posted by: Rick James
Date: August 19, 2009 09:01PM

Since the optimizer is run on EVERY SELECT, it does not matter whether it actually does the work -- the elapsed time is the 'same'.

Note: "prepare" does NOT create a query plan -- that is not done until the "execute" is run.

Even without subqueries, there is "execution" stuff that goes on. Example:
mysql> select * from users;
+------+-------+
| id   | misc  |
+------+-------+
| 1234 | adzzz |
+------+-------+
1 row in set (0.00 sec)

mysql> explain select * from users where id = 9999;
+----+-------------+-------+------+---------------+------+---------+------+-----
-+-----------------------------------------------------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows
 | Extra                                               |
+----+-------------+-------+------+---------------+------+---------+------+-----
-+-----------------------------------------------------+
|  1 | SIMPLE      | NULL  | NULL | NULL          | NULL | NULL    | NULL | NULL
 | Impossible WHERE noticed after reading const tables |
+----+-------------+-------+------+---------------+------+---------+------+-----
-+-----------------------------------------------------+
1 row in set (0.00 sec)
Note how it at least reached into the index to discover that there is no 9999.

The 13 hours was part of the SELECT, just like it was virtually all of the EXPLAIN.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: MYSQL optimizer: Handling Subqueires
2023
August 19, 2009 09:01PM


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.