Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 519985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:05:52+00:00 2026-05-13T08:05:52+00:00

What is the meaning of Select tables optimized away in MySQL Explain plan? explain

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:05:53+00:00Added an answer on May 13, 2026 at 8:05 am

    It means you have done a query that does nothing more than count the number of rows in a table, and that table is a MyISAM table. MyISAM tables are stored with a separate row count, so to do this query MySQL doesn’t need to look at any of the table row data at all. Instead it immediately returns the pre-calculated row count. Hence the table access is ‘optimized away’ and the query is lightning-fast.

    The same won’t happen on other storage engines in MySQL such as InnoDB. But really, you want to be using InnoDB and not MyISAM in most cases for a variety of other reasons. (And even without the row count optimisation this kind of query is very, very fast.)

    select count(comment_count) from wp_posts;
    

    Is that what you really meant to do? That’s the same as just SELECT COUNT(*)... (assuming comment_count can’t be NULL, which it can’t be or you wouldn’t have got the optimisation). If you want a total of the comment_count​s you should be using SUM(comment_count), and you won’t get the ‘optimized away’ behaviour.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SELECT var1,var2,var3,table_name FROM table1 LEFT JOIN table_name on var3=table_name.id Meaning I want to dynamically
Here's my query, it is fairly straightforward: SELECT INVOICE_ITEMS.II_IVNUM, INVOICE_ITEMS.IIQSHP FROM INVOICE_ITEMS LEFT JOIN
Sometimes phpMyAdmin generates queries like: SELECT * FROM `items` WHERE 1 LIMIT 0 ,
I have a table with some data in it: ColA | ColB | ColC
I'm working with your standard three table tag setup item_table item_id item_name tag_table tag_id
Quick question, I have a table of messages each with a timestamp and a
Can anybody tell me the meaning of ew:CalendarPopup ID=ucCalendar runat=server Width=80px ImageUrl=~/images/calendar.gif ControlDisplay=LabelImage ShowGoToToday=True
I have a fairly complicated join query that I use with my database. Upon
for some reason the below code is outputting the correct ticker in the location
I keep getting the following InvalidOperationException : The relationship between the two objects cannot

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.