What is the meaning of Select tables optimized away
in MySQL Explain plan?
explain select count(comment_count) from wp_posts; +----+-------------+---------------------------+-----------------------------+ | id | select_type | table,type,possible_keys, | Extra | | | | key,key_len,ref,rows | | +----+-------------+---------------------------+-----------------------------+ | 1 | SIMPLE | all NULLs | Select tables optimized away| +----+-------------+---------------------------+-----------------------------+ 1 row in set (0.00 sec)
Note: explain plan
output edited for legibility.
The select_type value for non- SELECT statements displays the statement type for affected tables. For example, select_type is DELETE for DELETE statements. table (JSON name: table_name ) The name of the table to which the row of output refers.
The key column in the output row indicates which index is used. The key_len contains the longest key part that was used.
The filtered column indicates an estimated percentage of table rows that will be filtered by the table condition. That is, rows shows the estimated number of rows examined and rows × filtered / 100 shows the number of rows that will be joined with previous tables.
The EXPLAIN statement provides information about how MySQL executes statements: EXPLAIN works with SELECT , DELETE , INSERT , REPLACE , and UPDATE statements. When EXPLAIN is used with an explainable statement, MySQL displays information from the optimizer about the statement execution plan.
From the MySQL documentation:
The query contained only aggregate functions (MIN(), MAX()) that were all resolved using an index, or COUNT(*) for MyISAM, and no GROUP BY clause. The optimizer determined that only one row should be returned.
Basically this means your query uses data that is directly available to MySQL and the query will run in constant time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With