Why mysql explain analyze is not working?

Viewed 5595

Besides having mariadb 10.1.36-MariaDB I get following error.

EXPLAIN ANALYZE select 1
MySQL said: Documentation

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ANALYZE select 1' at line 1

What additional I need to do here. My PHP version is 7.2.11.

1 Answers

As you can see in the docs https://mariadb.com/kb/en/explain-analyze/

The syntax for the EXPLAIN ANALYZE feature was changed to ANALYZE statement, available since MariaDB 10.1.0. See ANALYZE statement.

So just use ANALYZE ... without the explain keyword and you'll get the same output you got in the past.

In the analyze docs you have the info for the ANALYZE statement, you can see it's the same that the deprecated EXPLAIN ANALYZE.

The ANALYZE statement is similar to the EXPLAIN statement. ANALYZE statement will invoke the optimizer, execute the statement, and then produce EXPLAIN output instead of the result set. The EXPLAIN output will be annotated with statistics from statement execution.

The syntax is

ANALYZE explainable_statement;

where the statement is any statement for which one can run EXPLAIN.

Related