A 4B AI model speeds up Postgres queries by testing better plans
Rohan Bansal reports a 44.7% cut in benchmark query time after testing up to 15 candidate plans per query. The AI tunes Postgres; it does not replace the database.

The actual story.
Bansal trained a four-billion-parameter model with supervised fine-tuning and reinforcement learning to propose Postgres query-plan changes. His experiment used 113 join-heavy queries from the Join Order Benchmark.
The strongest result came from choosing among up to 15 candidates per query using measured feedback: a 1.81× total-workload speedup, equivalent to 44.7% less execution time. The model's own final choices achieved a smaller 1.24× workload speedup in the same three-rollout evaluation. These are different selection methods, not interchangeable results.
The gains included changing join order, scan methods and parallel execution. pg_hint_plan's documentation explains those controls; PostgreSQL's EXPLAIN guide explains how to inspect plans and measure execution. Postgres still runs the queries.
The headline improvement measures the selected plans, not an end-to-end saving after model inference and candidate testing. This is a reported benchmark result, not proof of the same improvement on a production workload.
The practical target is a slow query you run repeatedly, not every query on demand. Extra plan-search work can pay off if the resulting saving recurs often enough. Before adopting this approach, measure search cost against repeat-run savings on your own workload; a faster winning plan alone does not establish a cheaper system.
Receipts, not rumors.
- Rohan Bansal: experiment, evaluation table and candidate-selection method
- PostgreSQL documentation: inspecting plans and measuring execution
- pg_hint_plan documentation: join-order, scan and parallel-execution hints
Read the original reporting: rohanbansal.com
The reporting above provides context. Illustrations are editorial interpretations, not source photographs.

What’s your take?