Recommend prewarm targets
recommend_prewarm_targetsRecommends PostgreSQL relations whose first-query latency would benefit from pg_prewarm by analyzing cold-miss rates and seq_scan dominance, capped to a shared_buffers budget.
Instructions
Recommend relations whose first-query latency would benefit from pg_prewarm. Inspects pg_stat_user_tables + pg_statio_user_tables to find high cold-miss-rate / seq_scan-dominant relations, and caps the cumulative cost at shared_buffers_budget_pct * shared_buffers so the recommendation never silently exceeds shared_buffers. The advisor is read-only — never invokes pg_prewarm itself. Returns an object with shared_buffers_blocks (configured shared_buffers in 8 KiB pages), budget_blocks (the cap), total_cost_blocks (sum of recommendations actually returned), and candidates — a list of objects with schema, relation, reason (seq_scan_dominant / high_cold_miss_rate / small_hot_relation_uncached / index_in_critical_path), prewarm_mode, estimated_buffer_cost, heap_blks_read, heap_blks_hit, cache_miss_ratio, and ready_to_run_sql.
Example: recommend_prewarm_targets(shared_buffers_budget_pct=60.0, limit=10)
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": "recommend_prewarm_targets"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| database | No | Optional: a database id from list_databases, to target a configured secondary (read-only) database; omit for the primary. Database names that are not configured ids are rejected. | |
| prewarm_mode | No | buffer | |
| min_heap_blks_read | No | ||
| shared_buffers_budget_pct | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| candidates | Yes | ||
| budget_blocks | Yes | ||
| total_cost_blocks | Yes | ||
| shared_buffers_blocks | Yes |