Skip to content

Commit 36ab588

Browse files
authored
Use the prepared statement performance schema if available (#960)
Possibly resolves #937
1 parent 0496233 commit 36ab588

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

spec/mysql2/statement_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
end
77

88
def stmt_count
9+
# Use the performance schema in MySQL 5.7 and above
10+
@client.query("SELECT COUNT(1) AS count FROM performance_schema.prepared_statements_instances").first['count'].to_i
11+
rescue Mysql2::Error
12+
# Fall back to the global prepapred statement counter
913
@client.query("SHOW STATUS LIKE 'Prepared_stmt_count'").first['Value'].to_i
1014
end
1115

0 commit comments

Comments
 (0)