Skip to content

Instantly share code, notes, and snippets.

@lefred
Last active May 18, 2023 07:03
Show Gist options
  • Save lefred/9084377fd62743b412f79a8535c90a9a to your computer and use it in GitHub Desktop.
Save lefred/9084377fd62743b412f79a8535c90a9a to your computer and use it in GitHub Desktop.
it there should be only one query to optimize in MySQL
SELECT schema_name, format_pico_time(total_latency) tot_lat,
exec_count, format_pico_time(total_latency/exec_count) latency_per_call,
query_sample_text
FROM sys.x$statements_with_runtimes_in_95th_percentile AS t1
JOIN performance_schema.events_statements_summary_by_digest AS t2
ON t2.digest=t1.digest
WHERE schema_name NOT in ('performance_schema', 'sys')
ORDER BY (total_latency/exec_count) desc LIMIT 1\G
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment