get_index_recommendations
Analyze PostgreSQL query workload to identify performance bottlenecks and generate optimal index recommendations that improve database performance.
Instructions
Get AI-powered index recommendations for your database.
Analyzes your query workload (from pg_stat_statements) and recommends indexes that would improve performance. Uses a sophisticated analysis algorithm that:
Identifies slow queries and their access patterns
Extracts columns used in WHERE, JOIN, ORDER BY, and GROUP BY clauses
Generates candidate indexes (single-column and composite)
If HypoPG is available, tests indexes without creating them
Uses a greedy optimization algorithm to select the best index set
Note: This tool focuses on user/client tables only and excludes system catalog tables (pg_catalog, information_schema, pg_toast).
The recommendations consider:
Query frequency and total execution time
Estimated improvement from each index
Index size and maintenance overhead
Avoiding redundant indexes
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_index_recommendations"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workload_queries | No | Optional list of specific queries to analyze. If not provided, uses pg_stat_statements. | |
| max_recommendations | No | Maximum number of index recommendations to return | |
| min_improvement_percent | No | Minimum improvement percentage for a recommendation to be included | |
| include_hypothetical_testing | No | Whether to test indexes using HypoPG (if available) | |
| target_tables | No | Optional list of tables to focus on |