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

The article shows that a small 4B open-weights model, post-trained with supervised fine-tuning and reinforcement learning, can generate PostgreSQL query plans that materially outperform the database’s default optimizer—cutting latency by 44.7% across 113 join-heavy queries and reaching up to 81% faster plans in some cases. For CIOs and technology leaders, the strategic takeaway is that AI can be applied to narrowly defined, high-value infrastructure problems where outcomes are easy to measure, creating a path to better application performance, lower compute costs, and differentiated database operations. For IT organizations, this points to a future where DBAs, platform teams, and ML engineers collaborate on workload-specific optimization layers rather than relying solely on built-in query optimizers.

Hacker News3 min read
Read full article
Training a 4B model to produce 81% faster query plans than Postgres

Read the full story at Hacker News →