Skip to content
Hacker News front page

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

Rohan Bansal post-trained a Qwen 4B model to beat Postgres's default query plans. After SFT distillation from 500 GPT-6 Astra trajectories and a custom GRPO variant for RL, the model achieved 44.7% latency reduction and 81% geometric mean speedup across 113 join-heavy queries. Training ran on a rented 2×H100 node with four Postgres containers on his desk for measurement. The post doesn't disclose total training time or per-inference latency.

Why it matters: A 4B model post-trained with supervised fine-tuning plus agentic RL to write Postgres query plans cut latency 44.7% across 113 multi-table join queries, with the full training pipeline documented for small-model query optimization.

Read the original ↗Export Markdown