How to get a query plan from a prepared statement

I don't remember ever seeing a way to use prepared statements from the console and for some reason didn't think that an explain request was running since the prepared API statement would get what I want.

This is related to an old question of mine .

I'm primarily interested in MySQL, but it will be interesting for other databases as well.

+2


source to share


1 answer


According to the brief research I have done, I see no way to get it. Ideally, the real execution plan will be generated after the variables are provided. Lookup tables can quickly eliminate the actual run of a query if the constant is missing. The ideal execution plan would take into account the frequency of occurrence. My understanding is that MySQL is at least used to prepare an execution plan when a statement is prepared to test an expression. Then, when you execute it, it generates a different plan of explanation.

I believe the explain plan is temporarily hosted in a table in MySQL, but is quickly deleted after using it.

I would suggest asking for a list of MySQL internals.



Luck,

Jacob

+2


source







All Articles