When using the "MySQL Native ODBC Driver" for a SiteMinder Policy Store or Session Store, the number of prepared statement objects in the MySQL "performance_schema" continues to grow indefinitely.
Monitoring the "performance_schema.prepared_statements_instances" table (1) shows unique entries for queries that include timestamp or session data, such as:
This behavior occurs even if server-side prepared statements are not explicitly intended, leading to potential memory overhead on the database server.
The following statement is used to count the occurence of these statement from a Policy Store:
SELECT owner_thread_id, t.processlist_user AS user, t.processlist_host AS host, t.processlist_db AS database_name, COUNT(*) AS numero_prepared_stmt FROM performance_schema.prepared_statements_instances p JOIN performance_schema.threads t ON p.owner_thread_id = t.thread_id GROUP BY owner_thread_id, t.processlist_user, t.processlist_host, t.processlist_db;
The result is:
| owner_thread_id | user | host | database_name | numero_prepared_stmt | |-----------------+--------+--------------------+---------------+----------------------| | 9032163 | smuser | server.example.com | <PolicyStore> | 78 | | 9021668 | smuser | server.example.com | <PolicyStore> | 106 |
By default, the MySQL Native ODBC driver may send statements to the server for preparation even if the application (Policy Server) has not explicitly requested a server-side prepared statement for that specific execution (2).
Because SiteMinder queries (like "smservercommand4" polls) frequently change the "WHERE" clause values, the MySQL server treats each unique string as a new prepared statement instance, filling up the "prepared_statements_instances" table.
To prevent the driver from creating these objects on the MySQL server, enable "Client-Side Preparation".
Note:
If using a connection string or "system_odbc.ini" file on Linux, ensure the following parameter is set:
"NO_SSPS=1" (3) (or "PREPONCLIENT=1" (4) depending on specific driver builds).