Recommend Redis cache targets
recommend_redis_cache_targetsIdentifies read-heavy, low-write database tables suitable for Redis caching by analyzing pg_stat_user_tables statistics. Returns recommended tables with SQL stubs for creating foreign tables.
Instructions
Recommend tables that would benefit from a Redis cache layer. Inspects pg_stat_user_tables for read-heavy, low-write relations whose working set fits comfortably in Redis (default: read/write ratio ≥ 10, ≥ 1000 reads, ≤ 1M rows). When server is provided the generated ready_to_run_sql stub targets that server name; otherwise the stub uses a placeholder operators must substitute. Advisor is read-only — never touches Redis itself. Returns an object with server and candidates — a list of objects with schema, table, reads, writes, read_write_ratio, estimated_row_count, reason (read_only_lookup_table / small_hot_relation / read_heavy_low_write / moderate_read_dominant), and ready_to_run_sql (a CREATE FOREIGN TABLE stub).
Example: recommend_redis_cache_targets(server='redis_primary', limit=10)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| server | No | ||
| database | No | Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids. | |
| max_rows | No | ||
| min_reads_per_day | No | ||
| min_read_write_ratio | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| server | Yes | ||
| candidates | Yes |