ML-Driven Query Planning: 81% Faster or Just Unstable?

Sources

The claim: A 4B parameter model can produce query plans 81% faster than standard Postgres heuristics. On paper, this is a massive win for complex JOIN-heavy workloads where the cost-based optimizer (CBO) often hallucinates the cardinality of skewed distributions.

The Technical Shift

Traditional Postgres planning relies on statistics (histograms, most common values) and a cost model. When stats are stale or correlations are complex, the planner picks a nested loop where a hash join was required, and the query hangs. Moving this to a model shifts the problem from statistical estimation to pattern recognition.

The "Catch": Plan Stability

For a Platform Engineer, "81% faster" is a vanity metric if the 99th percentile latency spikes because the model occasionally picks a catastrophic plan. Heuristic planners are boring, but they are deterministic. ML planners introduce "Plan Drift." If the model's training distribution doesn't match your production data skew, you're not getting a faster query—you're getting a random lottery of execution times.

Who Should Skip

If your workload is highly predictable or if you have strict SLAs on tail latency, stay away. The operational burden of monitoring "plan regressions" caused by a black-box model outweighs the average-case gain. This is for teams with massive, unpredictable analytic queries where the current CBO is already failing.

Verdict

Impressive research, but a nightmare for SREs who hate non-deterministic performance. Great for data science labs; terrifying for production banking cores.