HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlModerate

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

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
estimateexecutingtheanyquerywaymysqlgetcostthere

Problem

In PostgreSQL, EXPLAIN or EXPLAIN ANALYZE will show the estimate cost of executing a query. But EXPLAIN in MySQL doesn't provide this information. How can I get the estimate cost without installation of other tools? I'm using MySQL-5.6.16.

Solution

In short

  • Run your SELECT ... query



  • SHOW STATUS LIKE 'last_query_cost'



  • if the answer was 0 rerun the query with


select SQL_NO_CACHE ... and do step 2 above again

Context

StackExchange Database Administrators Q#62029, answer score: 10

Revisions (0)

No revisions yet.