Training a 4B model to produce 81% faster query plans than Postgres

A 4B open-weights model, post-trained with reinforcement learning, generates Postgres query plans that reduce latency by 44.7% on join-heavy workloads. The author details the training rig, including a custom GRPO variant and measurement setup to isolate page cache noise. While the results are specific to the tested dataset, the technique offers a practical path for developers seeking to optimize complex

Cover image for Training a 4B model to produce 81% faster query plans than Postgres