Show Slow Queries from pg_stat_statements
pg_slow_queriesAnalyze slow database queries using pg_stat_statements, ranked by mean execution time, to identify performance bottlenecks.
Instructions
Analyze slow queries using the pg_stat_statements extension. Shows queries ranked by mean execution time.
Requires the pg_stat_statements extension to be installed and enabled.
Args:
limit: Number of queries to return (default: 20, max: 100)
min_calls: Only show queries called at least N times (default: 5)
order_by: Sort by 'mean_ms', 'total_ms', or 'calls' (default: mean_ms)
response_format: Output format
Returns: JSON: { queries: SlowQuery[], count: number } Markdown: table with calls, mean/total time, % of total, cache hit %, query text
Errors:
"pg_stat_statements extension not installed" if extension is missing
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of queries to return | |
| min_calls | No | Minimum number of calls to include | |
| order_by | No | Sort order | mean_ms |
| response_format | No | Output format: 'markdown' for human-readable, 'json' for machine-readable | markdown |