Hola Ricardo,
Ricardo Conrado Serafim wrote:
Hi group,
Someone can answer me if when I execute the "explain" in a select
statement, the select is executed to get the parameters or this
information came from other place? In other words, the explain covers
the table and indexes or it calculate based on numbers of rows, etc.
When you run EXPLAIN it asks the MySQL server to parse and validate the query.
MySQL then builds a tree that represents the execution plan. It tries many
plans until it finds what it thinks is the best plan. EXPLAIN is directly
generated from this plan.
The query is not executed, but the query optimizer uses table statistics to help
it find what it thinks will be the least expensive query plan. It maintains
statistics about tables and indexes, and can sometimes answer some questions
like "what is the maximum value in this index" during the optimization phase.
The only case I know where EXPLAIN actually executes a query is if you have a
subquery in the FROM clause, like this:
select ...
from (
select ...
)
The optimizer has to execute the inner query and put it into a temporary table
to build the rest of the query.
I hope this helps.
Baron
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]