Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count of all prepared statements (all connections) in mysql

My question is similar to How to list all prepared statements for all active sessions?, but for MySQL.

I have a program (prosody XMPP server) that seems to be leaking prepared statements. To diagnose the problem, I want a list of all "open" prepared statements. (even prepared statements by 'dead' connections, if such exist)

The statements in question are, as far as I can tell, all created by the MySQL user 'prosody', so I'd like to list all statements created by this user. However, it'd be also nice to have a list of all statements for all users.

I am not fully aware of the prepared statement's lifecycle/possible states, so details in that regard are very welcome.

like image 848
josinalvo Avatar asked Oct 07 '16 04:10

josinalvo


1 Answers

It turned out to be very simple:

SHOW GLOBAL STATUS LIKE '%prepared_stmt_count%';
like image 140
josinalvo Avatar answered Sep 19 '22 18:09

josinalvo