Is there any way to get the estimate cost of executing a query in MySQL?

In short

  1. Run your SELECT ... query
  2. SHOW STATUS LIKE 'last_query_cost'
  3. if the answer was 0 rerun the query with select SQL_NO_CACHE ... and do step 2 above again

There isn't much out there for MySQL except the following:

  • EXPLAIN EXTENDED followed by SHOW WARNINGS
  • SHOW PROFILES (Older Releases of MySQL)
  • MySQL PERFORMANCE_SCHEMA

Read these carefully, see what you think ...