Recommend redistribute
recommend_redistributeDiagnoses distribution skew in hash-distributed tables by analyzing column cardinality. Suggests an improved distribution key and generates ALTER TABLE DDL for rebalancing.
Instructions
Distribution-skew advisor for a hash-distributed table. Reads pg_stats.n_distinct for every column on the table and suggests a better hash key when the current one is low-cardinality. Pure catalog read — no per-segment scans. Returns ranked candidates, optional recommendation, and ready-to-review suggested_ddl (ALTER TABLE … SET WITH (REORGANIZE=TRUE) DISTRIBUTED BY (col)). Diagnosis-only — never executes. On vanilla PG returns available=false.
Example: recommend_redistribute(schema='public', table='fact_sales')
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | ||
| schema | Yes | ||
| database | No | Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | ||
| detail | Yes | ||
| schema | Yes | ||
| available | Yes | ||
| candidates | Yes | ||
| suggested_ddl | Yes | ||
| current_method | Yes | ||
| recommendation | Yes | ||
| current_columns | Yes |