Database Index Advisor & Composite B-Tree Optimizer
recommend_database_indexesAnalyzes slow SQL queries and recommends single-column or composite B-tree/BRIN indexes from WHERE, JOIN, and ORDER BY clauses to reduce full-table scans and improve response times.
Instructions
Recommends optimal single-column and composite B-Tree/BRIN indexes based on slow query WHERE, JOIN, and ORDER BY clauses. Use when optimizing database response times and eliminating full-table scans; for inspecting full execution plans, use analyze_query_plan instead. Stateless read-only edge call (max 32 KB, 60 RPM): accepts 'slow_queries_or_workload' ('index_type_preference' defaults to 'btree_and_composite'), supports '?demo=true' or L402 (15 sats), and returns HTTP 400 if invalid.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| max_new_indexes | No | Maximum number of index creation statements to recommend. | |
| index_type_preference | No | Target indexing strategy: B-tree and composite, BRIN and GIN sparse, or covering indexes with INCLUDE. | |
| slow_queries_or_workload | Yes | Collection of slow SQL queries or workload log statements to analyze for index gaps. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| recommended_indexes | Yes | List of recommended CREATE INDEX DDL statements with target columns. | |
| storage_overhead_est | Yes | Estimated index disk storage footprint overhead impact. | |
| expected_speedup_factor | Yes | Estimated average query execution speedup multiple (e.g. 14.5x). |