analyze_workload_indexes
Recommends indexes for a Postgres workload by testing hypothetical candidates against pg_stat_statements queries, returning CREATE INDEX statements with estimated sizes and costs without creating them.
Instructions
Recommend indexes for this database's workload: the pg_stat_statements queries with at least 50 calls and 5 ms mean time, up to 100 by total time. Candidates are indexes on 1 to 3 columns that the queries filter, join, sort or group on, each tried as a hypothetical index (hypopg) and compared by planner cost. A greedy search adds one at a time while an addition lowers the workload cost by at least 10%, is worth its size and keeps the total within max_index_size_mb; it ends 30 seconds after the analysis starts, keeping what it has chosen by then. Nothing is created. Returns CREATE INDEX statements with estimated sizes and costs, skipped queries with reasons, and each query's cost before and after. Needs pg_stat_statements and hypopg. For queries you choose, use analyze_query_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": "analyze_workload_indexes"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| max_index_size_mb | No | Size budget for all recommended indexes together, in MB (default 10000); a candidate that would take the total over it is not added |