by rubyrescue · 16y ago · 0 comments
update: NVM!
http://dev.mysql.com/tech-resources/articles/mysql-query-cac...
Which is disappointing. I will go look at Postgres... and it seems to cache only at a lower level (indices, tables etc).
The only reason I can think of for a query with different literals in the conditionals to have a different plan would be if a histogram of frequencies was actually kept such that different literals created large differences in result sizes which then get fed into a join and affect the join logic. But that's going to be pretty rare and is a level of optimization that is unnecessary. It's also not going to make a huge difference unless the query is very complex, because the plans for simple queries are... simple.
if you cache the statement then you get a miss if the different literals change. remember that (again, unless i have misunderstood) we are not talking about compiled statements, but about linq generate the "complete text".
i agree that the same plan would normally be used; the problem is hitting the cache to find that plan if the value of a variable changes.