Analyze MPP query plan
analyze_mpp_query_planRun EXPLAIN ANALYZE with JSON output on a SQL query and extract MPP-specific metrics: motion nodes, slice count, and sender/receiver details, with a flag for data co-location issues.
Instructions
Run EXPLAIN (ANALYZE, FORMAT JSON) on sql and roll up MPP-specific facts: slice count, motion nodes (Redistribute Motion / Broadcast Motion / Gather Motion), and per-motion metadata (senders, receivers, estimated rows). Uses the same safety pre-flight as analyze_query_plan(io=True) — writes / DDL stay rejected. redistribute_count flags 'data is not co-located with the join key'. On vanilla PG returns available=false.
Example: analyze_mpp_query_plan(sql='SELECT * FROM big JOIN small ON big.k = small.k')
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | 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 |
|---|---|---|---|
| detail | Yes | ||
| motions | Yes | ||
| available | Yes | ||
| slice_count | Yes | ||
| gather_count | Yes | ||
| motion_count | Yes | ||
| broadcast_count | Yes | ||
| redistribute_count | Yes |