Startup fine-tunes 4B open-weights model to beat Postgres's own query planner
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.