Skip to content
Tech News
← Back to articles

Startup fine-tunes 4B open-weights model to beat Postgres's own query planner

read original more articles
GoKawiil Brief

An independent researcher used supervised fine-tuning and agentic reinforcement learning to train a small 4B-parameter open-weights language model to generate PostgreSQL execution plans. On a set of 113 join-heavy queries, the tuned model cut latency by 44.7% on average compared to Postgres's default planner, even though the base model initially failed to produce valid plans for 99 of those queries. The project also involved building a custom measurement rig to reduce caching noise and a modified GRPO reinforcement learning method for scoring plans in a noisy environment.

Why It Matters

GoKawiil's interpretation of the reporting above, not reported fact.

Query optimization, especially join ordering, is an NP-hard problem that traditional database planners still struggle with despite decades of research. This experiment suggests that machine learning models trained with reinforcement learning on verifiable execution-time signals could eventually augment or replace hand-tuned heuristics in production databases, potentially yielding significant performance gains without rewriting the database engine itself.

Key Takeaways

Source: rohanbansal.com, 2026-09-16

Published there as: “Training a 4B model to produce 81% faster query plans than Postgres”

Read the original report → The summary and analysis above are GoKawiil's own, written from reporting by the source above. Facts and quotes belong to the original publisher.