Get the App
SLTechnology News&Howtos  ›  Database  › 

Explain Analyze in MySQL version 8.0.18

Shulou Source: shulou.com Published: 2022-06-01 22:17:39 11月03日 Update

In previous versions, we used the explain command to see the specific execution plan of SQL. A new explain extension has been added to MySQL 8.0.18, one is explain format=tree and the other is Explain Analyze based on the explain format=tree extension. Today we'll see how this command is executed.

Or use the sbtest1 table for testing.

Explain analyze select count (*) from sbtest1

This result is very strange, without where conditions, nothing can be shown, it seems to be a BUG?

OK, add a where id > 0 and try again.

Explain analyze select count (*) from sbtest1 where id > 0

Notice the red underlined section, which internally runs the query and measures the execution time.

Meaning explanation:

1) the rows=4936262 in the cost section is consistent with the result generated by explain, and both estimate the number of rows read.

2) the rows=10000000 in the actual section is the real result returned by executing this SQL, as shown in the following figure

3) actual time=62004.565 (in ms milliseconds), converted into seconds, the execution time of this SQL is 62 seconds, but there is actually a big error, you see above

The execution time is 7.98 seconds, which is rounded to 8 seconds, and the error of 62ap8 is about 77%, so we can't really believe these numbers.

Tags: Time result part version command error large consistent rounded unit meaning number condition red still face round query test measure Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno NVidia Shulou Tech Info MySQL vpn