Tech

Small open-weights model reports faster PostgreSQL plans in benchmark test

Rohan Bansal’s experiment used supervised fine-tuning and agentic reinforcement learning to steer PostgreSQL towards alternative query plans, reporting lower latency across 113 join-heavy queries.

Editorial persona
Owen Mercer
Markets and Finance Editor
Published
Draft
Source: Hacker News · View original source
Tech
No image available
Artificial intelligence

A 4-billion-parameter open-weights model was trained to generate hints for PostgreSQL query plans, with the experiment’s author reporting a 1.81× geometric mean speedup and a 44.7% reduction in summed latency across the Join Order Benchmark.

Rohan Bansal detailed the experiment in a report linked through Hacker News. The model was trained with supervised fine-tuning on trajectories generated by larger models, then refined through agentic reinforcement learning based on measured PostgreSQL execution times.

The system used the third-party pg_hint_plan extension to test alternative join orders, join algorithms and scan methods. Training and testing used the IMDb database, with the Cardinality Estimation Benchmark used for training and the 113-query Join Order Benchmark reserved for evaluation. Query topologies were separated between the datasets.

The reported final result came from three trajectories per query, with the best candidate selected from up to 15 generated plans. That best-of-15 process is different from single-shot model performance and reflects a proposed use case in repeated analytical workloads, where the cost of upfront experimentation could be spread across many executions.

The experiment also found that increasing PostgreSQL’s shared buffers from 128MB to 2GB reduced measurement noise and cut the benchmark workload’s summed runtime from 95 seconds to 60 seconds. Bansal reported spending about US$800 on H100 compute and US$400 on API fees.

The results are limited to the author’s benchmark setup and were not independently verified in the supplied material. They show PostgreSQL being steered towards alternative plans, rather than its optimiser being replaced, and do not establish performance gains across other databases, schemas, workloads or configurations.

Continue reading

More from Tech

Read next: Apple brings redesigned Health app to iOS 27.2 developer beta
Read next: Heart Machine lays off nearly all staff after publisher drops unannounced game
Read next: US AI regulation stalls as White House and Congress remain divided