In my last post, I described a specific problem with prepared statements into which PERFORMANCE_SCHEMA can give visibility. That made me wonder whether PERFORMANCE_SCHEMA can also be used to identify other areas where prepared statements run into problems. The most significant problem tends to be leakage of prepared statements. This can inflate memory usage, both on the server and application side, and it’s not uncommon to find applications which fail to close prepared statements.
So the question is, what can PERFORMANCE_SCHEMA tell us about how connections close (or more importantly, fail to close) prepared statements?
At the most basic level, one can check the number of PREPARE statements executed compared to DEALLOCATE PREPARE, and you can do that using global status variables. You’re shooting for general equality between (Com_prepare_sql + Com_stmt_prepare) and (Com_stmt_close + …
[Read more]