I am currently facing an issue where my TOP SQL stats are displayed as "-" for all my queries. I am using an Aurora Mysql 8.0.mysql_aurora.3.04.0 database.
After further investigation I came to the conclusion that this is only happening for prepared statements. I am using a NodeJS ORM for database communication which uses prepared statements for all their queries.
Reproducing this issue is easy:
- Call a prepared statement like the following:
PREPARE stmt_name FROM 'SELECT * FROM my_table WHERE column1 = ?';
SET @param_value = 'some_value';
EXECUTE stmt_name USING @param_value;
DEALLOCATE PREPARE stmt_name;
- Notice that the query
FROM 'SELECT * FROM my_table WHERE column1 = ?'
gets logged in performance insights but its stats are not set.
- Now execute the query without using a prepared statement:
SELECT * FROM my_table WHERE column1 = <value>
- Notice how the query gets logged in performance insights with the stats values present.
I suspect that this has something to do with the way mysql records performance data from prepared statements as they are not recorded in performance_schema.events_statements_summary_by_digest
table but instead on performance_schema.prepared_statements_instances
table. Maybe RDS Performance Insights is having some issues pulling the stats data from the latter.
Any help is greatly appreciated, thanks!