SHOW ANALYZE
Retrieve runtime statistics for a currently executing query. This statement provides insights into query plan execution without waiting for completion.
Last updated
Was this helpful?
Was this helpful?
EXPLAIN format=json
SELECT sum(orders.amount)
FROM
customer JOIN orders ON customer.cust_id=orders.cust_id
WHERE
customer.status='GOLD';+------+-------------+----------+------+---------------+---------+---------+------------------+--------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+----------+------+---------------+---------+---------+------------------+--------+-------------+
| 1 | SIMPLE | customer | ALL | PRIMARY | NULL | NULL | NULL | 199786 | Using where |
| 1 | SIMPLE | orders | ref | cust_id | cust_id | 5 | customer.cust_id | 1 | |
+------+-------------+----------+------+---------------+---------+---------+------------------+--------+-------------+SHOW ANALYZE format=json FOR 3;
| {
"r_query_time_in_progress_ms": 32138,"query_block": {
"select_id": 1,
"r_loops": 1,
"nested_loop": [
{
"table": {
"table_name": "customer",
"access_type": "ALL",
"possible_keys": ["PRIMARY"],
"r_loops": 1,
"rows": 199786,
"r_rows": 110544,"filtered": 100,
"r_filtered": 9.538283398,
"attached_condition": "customer.`status` = 'GOLD'"
}
},
{
"table": {
"table_name": "orders",
"access_type": "ref",
"possible_keys": ["cust_id"],
"key": "cust_id",
"key_length": "5",
"used_key_parts": ["cust_id"],
"ref": ["test.customer.cust_id"],
"r_loops": 10544,
"rows": 1,
"r_rows": 99.99222307,"filtered": 100,
"r_filtered": 100
}
}
]
}
}Connection 1> ANALYZE SELECT ... ;Connection 2> SHOW ANALYZE FORMAT=JSON FOR <connection_id>;
ANALYZE
{
"r_query_time_in_progress_ms": 30727,
"query_block": {
"select_id": 1,
"r_loops": 1,
"nested_loop": [
{
"table": {
"table_name": "customer",
"access_type": "ALL",
"possible_keys": ["PRIMARY"],
"r_loops": 1,
"rows": 199786,
"r_rows": 109994,
"r_table_time_ms": 232.699,
"r_other_time_ms": 46.355,"filtered": 100,
"r_filtered": 9.085950143,
"attached_condition": "customer.`status` = 'GOLD'"
}
},
{
"table": {
"table_name": "orders",
"access_type": "ref",
"possible_keys": ["cust_id"],
"key": "cust_id",
"key_length": "5",
"used_key_parts": ["cust_id"],
"ref": ["test.customer.cust_id"],
"r_loops": 9994,
"rows": 1,
"r_rows": 99.99779868,
"r_table_time_ms": 29460.609,
"r_other_time_ms": 986.842,"filtered": 100,
"r_filtered": 100
}
}
]
}
}