19

Is there a way to explain a DELETE query with MySQL like we can explain a SELECT query?

3 Answers 3

39

"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

Sign up to request clarification or add additional context in comments.

Comments

10

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.

Comments

1

No, that's not quite right. A DELETE would also remove index entries from any associated indexes (mysql erroneously calls them 'keys'). There are also delete triggers to consider as well.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.