Mysql – Why can’t I view the plan for view creation…

MySQLperformancequery-performance

mysql> EXPLAIN EXTENDED
    create algorithm =temptable view fisgen_temptable(inter,phone)
    as select intercom1,phone from fisgen where fid='f105';

I am getting an error like this:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'create
algorithm =temptable view fisgen_temptable(inter,phone)
as select interc' at line 2

Best Answer

EXPLAIN shows an execution plan for SELECT queries. In version 5.6, it was extended to include plans for INSERT, UPDATE, DELETE and REPLACE statements.

No version of MySQL (not even the still in development, 5.7) has EXPLAIN for CREATE TABLE or CREATE VIEW.

You can of course run the explain for the select (that defines the view):

EXPLAIN EXTENDED
    select intercom1,phone from fisgen where fid='f105';

or as @jynus suggested (thank you), the more useful:

EXPLAIN EXTENDED
    select * from fisgen_temptable;
Related Question