Vibeleaderboard
← All Intel
Intel / article

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

Source
rohanbansal.com
Author
polyphilz
Date
From the Daily Brief

An independent researcher trained a 4B parameter Qwen model with agentic reinforcement learning against a live Postgres measurement rig, having it propose query hints and then measuring the actual execution time of each proposal rather than relying on a static cost model. Across 113 join heavy queries from the Join Order Benchmark, the trained model's hints cut latency by up to 44.7% compared to Postgres's own query planner. Query planning is a narrow, well studied problem where small models trained against a real feedback loop can sometimes beat a mature general purpose system, because the model only needs to learn patterns specific to the workload it sees during training rather than handle every possible query shape. The result does not mean the model outperforms Postgres broadly. It was trained and measured on one benchmark's query distribution, and hint based approaches carry known risks if the underlying data or query patterns shift after training. Still, the technique is a reusable pattern for anyone willing to build a similar measurement rig: use a small model as a learned optimizer for narrow, measurable subproblems where the cost of running many candidate proposals is cheap. That pattern extends well beyond databases.

Read the 2026-09-17 Brief →

Context

A four-billion-parameter model was trained to suggest ways for Postgres to execute queries, then learn from measured execution times. The experiment targets repeatedly run analytical queries, where testing alternative plans upfront could pay off over later executions.

The headline result used three attempts per query, each allowing up to five candidate plans, and picked the best measured candidate. Across 113 Join Order queries, the author reports a 1.81-fold workload speedup, equivalent to 44.7% less summed execution time. The model's own unaided selections scored lower, about 1.24-fold on workload, and the article does not say whether search and measurement time is counted. Training and used different query templates on the same IMDb database, and evaluation runs were mostly single runs.

Terms in this piece · Glossary
  • benchmark — A standard public test set for comparing AI models — the shared scoreboards behind every "model X beats model Y" claim.
  • eval — A repeatable test for AI quality — a set of tasks plus scoring — used the way software teams use test suites, because model output is too variable to judge by eyeballing.
Read the source rohanbansal.com
Recommended reads
Comments

Checking sign-in…

Loading comments…