Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why mysql explain analyze is not working?

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.

like image 274
Hrushikesh Vartak Avatar asked Mar 22 '20 09:03

Hrushikesh Vartak


People also ask

How do I run an explain plan in MySQL?

To view a visual explain execution plan, execute your query from the SQL editor and then select Execution Plan within the query results tab. The execution plan defaults to Visual Explain , but it also includes a Tabular Explain view that is similar to what you see when executing EXPLAIN in the MySQL client.

Does explain actually run the query?

It tells you the execution plan. It doesn't execute the query (although it might execute subqueries).

What is filtered in explain MySQL?

The filtered column indicates an estimated percentage of table rows that will be filtered by the table condition. That is, rows shows the estimated number of rows examined and rows × filtered / 100 shows the number of rows that will be joined with previous tables.


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.

like image 91
jeprubio Avatar answered Oct 16 '22 20:10

jeprubio