I have a query
SELECT foo FROM bar WHERE some_column = ?
Can I get a explain plan from MySQL without filling in a value for the parameter?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
So long as you’re doing only an equals (and not a like, which can have short circuit affects), simply replace it with a value:
Since it’s not actually executing the query, the results shouldn’t differ from the actual. There are some cases where this isn’t true (I mentioned LIKE already). Here’s an example of the different cases of
LIKE:Foo– Can use an index scan if an index exists.%Foo– Requires a full table scan, even if an index existsFoo%– May use an index scan, depending on the cardinality of the index and other factorsIf you’re joining, and the where clause yields to an impossible combination (and hence it will short circuit). For example:
If the first and second parameters are the same, it has one execution plan, and if they are different, it will short circuit (and return 0 rows without hitting any data)…
There are others, but those are all I can think of off the top of my head right now…