The lede
Training a 4B model to write better Postgres query plans than Postgres
Rohan Bansal · made the Sunday
Bansal distilled 420 trajectories out of a frontier model into a 4B Qwen with a 21M-parameter LoRA, then ran RL against real query timings on Postgres containers on his own machine, and got a 1.81x geometric-mean speedup across the 113 join-heavy queries of the Join Order Benchmark. The genuinely instructive half is the noise: page-cache contention was producing phantom 5% speedups until he raised shared_buffers to 2GB, interleaved candidate and default runs, and took medians, which dropped the false-signal rate to 1.7% — without that, the reward was training the model on measurement artifacts. Total cost $1,200, and it is the clearest recent demonstration that a small model plus a tight feedback loop beats a big model with a vague one.