Is there a way to explain a DELETE
query with MySQL like we can explain a SELECT
query?
DELETE is a DML statement that removes rows from a table. A DELETE statement can start with a WITH clause to define common table expressions accessible within the DELETE . See Section 13.2. 15, “WITH (Common Table Expressions)”.
To permanently remove a table, enter the following statement within the MySQL shell: DROP TABLE table1; Replace table1 with the name of the table you want to delete. The output confirms that the table has been removed.
MySQL Delete command is used to delete rows that are no longer required from the database tables. It deletes the whole row from the table and returns count of deleted rows. Delete command comes in handy to delete temporary or obsolete data from your database.
In MySQL, DELETE is a Data Manipulation Language or DML, as we know. As the name itself suggests, the command is used to delete rows from the table. Using this command, we can delete one or more unwanted rows in one single transaction. There are multiple ways to delete records from a table using the DELETE command.
"As of MySQL 5.6.3, EXPLAIN provides information about SELECT, DELETE, INSERT, REPLACE, and UPDATE statements. Before MySQL 5.6.3, EXPLAIN provides information only about SELECT statements."
from http://dev.mysql.com/doc/refman/5.6/en/explain.html
Wouldn't the plan for that be the same as for a select 1 where....
with the same condition as your delete
query?
The 1
is so the optimizer isn't forced to pull any unneeded columns, it can only look at the columns it needs for the filtering conditions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With