pg_manage_query
Analyze and optimize PostgreSQL queries using EXPLAIN plans, identify slow queries, monitor query statistics, and reset performance metrics via customizable operations for enhanced database management.
Instructions
Manage PostgreSQL query analysis and performance - operation="explain" for EXPLAIN plans, operation="get_slow_queries" for slow query analysis, operation="get_stats" for query statistics, operation="reset_stats" for clearing statistics
Input Schema
Name | Required | Description | Default |
---|---|---|---|
analyze | No | Use EXPLAIN ANALYZE - actually executes the query (for explain operation) | |
buffers | No | Include buffer usage information (for explain operation) | |
connectionString | No | ||
costs | No | Include cost estimates (for explain operation) | |
format | No | Output format (for explain operation) | json |
includeNormalized | No | Include normalized query text (for get_slow_queries operation) | |
limit | No | Number of slow queries to return (for get_slow_queries operation) | |
minCalls | No | Minimum number of calls (for get_stats operation) | |
minDuration | No | Minimum average duration in milliseconds (for get_slow_queries operation) | |
operation | Yes | Operation: explain (EXPLAIN/EXPLAIN ANALYZE query), get_slow_queries (find slow queries from pg_stat_statements), get_stats (query statistics with cache hit ratios), reset_stats (reset pg_stat_statements) | |
orderBy | No | Sort order (for get_slow_queries and get_stats operations) | mean_time |
query | No | SQL query to explain (required for explain operation) | |
queryId | No | Specific query ID to reset (for reset_stats operation, resets all if not provided) | |
queryPattern | No | Filter queries containing this pattern (for get_stats operation) | |
verbose | No | Include verbose output (for explain operation) |