frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

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

https://rohanbansal.com/qorl
86•polyphilz•1h ago

Comments

fsmv•51m ago
But how will you know that the query plan actually does what your query asked for?
KK7NIL•50m ago
"... make no mistakes" :)
timcobb•48m ago
I imagine you can perform operations on query plans to transform them and determine equivalence?
polyphilz•42m ago
`pg_hint_plan` has a debug log so you can verify Postgres actually used the hint or not! Used this during evaluations
amluto•35m ago
I would like to think that pg_hint_plan is designed in such a way that any hint it accepts must be a valid plan for the query. I’m quite confident that schemes with this property that can also express high quality plans are possible and not even excessively complicated.

This is not to say that it’s possible to genetically verify that a proposed algorithm does what you want it to — that would be undecidable or NP-hard or co-NP-hard depending on how you formulate the question.

hedgehog•25m ago
I wouldn't be very excited about adding a 4B param model to my database deployment, but using this kind of approach while testing an app to identify query plans where Postgres is leaving performance on the table seems valuable without much risk.
kingjimmy•31m ago
Aren't optimizations suppose to be deterministic?
tintor•24m ago
They are not. Choice among several query plans depends on various summary statistics about the data, which might not be the most recent.
cogman10•18m ago
Including the input parameters.

It's not unusual for us to end up with bad query plans because the shape of our data can vary pretty greatly. In many cases, a Foo has 1 Bar. But in some cases, a Foo has a million Bars. That can cause the query optimizer to treat lookups on the bar table as if there are few elements there (causing a scan instead of a seek).

For the general case, the optimizer gets it right. However, the fringe case is one that causes the entire system to crash. It's a bit akin to how an insertion sort can be faster than quick sort when n is small. The optimizer might make a bad assumption about the size of n which makes it pick an expensive n lookup when log(n) is available (but slower for small n).

cowboylowrez•16m ago
I'd like to contribute my amateur hour entry into this thread, although I did administer and develop mssql stuff for awhile.

sure optimizations based on stats, but the stats are the wildcard, in my experience query plans can change suddenly.

Queries are translated into plans according to statistics. However the transforms will be deterministic and should only change one valid plan to another. I could very easily see a neural network manipulate transforms the same way the current programming does, its just that the neural networks are by nature really nicely suitable because the "decisions" are based on training, and this training can be closed world type things like the ai assists that chess engines are now getting. Obviously ai still can't play chess but apparently its very good at ranking board positions just by developing that much statistical info because its training comes not from reading the web, but playing a gazzilian games against itself in a "closed" chess world of its own.

I'm thinking that the ai does "this legal transform of the query plan should be applied to this pattern of data (statistics, cardinality, etc)" simply because the ai encountered it in closed world training, much like the chess thing.

Just a theory tho feel free to correct!

Someone•24m ago
> I paid ~$800 to rent a 2x H100 SXM node from Lambda for ~95 hours, and ~$400 in OpenAI API fees to generate the Astra trajectory demonstrations.

> a tiny 4B model went from not being able to understand the harness it was wrapped in, to achieving a 1.81x geometric mean speedup and a summed latency decrease of 44.7% across a workload of join-heavy SQL queries

I can’t find it in the article (may have skimmed it too much), but I suspect they didn’t include those ~95 hours in the benchmark numbers.

I think all database vendors know their query optimizers could do much better if they could afford to spend lots of time to derive query plans.

⇒ this may be useful for some workloads, but even then, can you afford to spend hours every now and then to update your 4B model to ensure it still picks a good query plan?

dvt•9m ago
> ⇒ this may be useful for some workloads, but even then, can you afford to spend hours every now and then to update your 4B model to ensure it still picks a good query plan?

I think this would be likely comparable to a scheduled backup, so I think it would be an acceptable maintenance window. However, deterministic algorithms would likely beat re-training (or re-fine-tuning) the model. For example, one could analyze actual distributions or whatever (instead of assuming uniform), and then some plans would automatically be eliminated.

Imo a good thought experiment is to look at places that are hyper-optimized, like compilers. Would LLMs bring anything to the table (architecturally or performance-wise) to a piece of software that has been carefully crafted for decades? (Methinks no.)

devsda•20m ago
> Frontier intelligence is extremely powerful; the distillation I did off Astra trajectories is proof enough that large models are not going anywhere

Wouldn't admitting this invite trouble due to accusations of distillation flying around between closed and open models.

Vectorized and performance-portable Quicksort (2022)

https://opensource.googleblog.com/2022/06/Vectorized%20and%20performance%20portable%20Quicksort.html
138•mococa•1h ago•20 comments

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

https://rohanbansal.com/qorl
100•polyphilz•1h ago•14 comments

Small programming tricks

https://will-keleher.com/posts/small-programming-tricks-matter/
243•signa11•4h ago•134 comments

Accurate Models of AMD Matrix Cores

https://arxiv.org/abs/2609.14845
28•matt_d•1h ago•2 comments

Dream-RSI: Recursive Self-Improvement through Evolving Worlds

https://arxiv.org/abs/2609.14858
150•bananaflag•6h ago•45 comments

Mistral X Mozilla: Private, Multilingual AI Browsing

https://mistral.ai/news/mistral-x-mozilla/
471•vertigoruntime•12h ago•168 comments

Tell the speakers that you liked their talks

https://ohhelloana.blog/tell-the-speakers/
222•whisper2020•1d ago•58 comments

Show HN: An e-ink frame that hears birds and draws them as 1800s illustrations

https://github.com/arnegiacomo/fugleramme
1969•arnemunthekaas•1d ago•230 comments

The Siberian Ice Maiden and the Scythian World

https://patrickwyman.substack.com/p/the-siberian-ice-maiden-and-the-scythian
25•NaOH•1d ago•0 comments

How big are factorials?

https://eli.thegreenplace.net/2026/how-big-are-factorials/
65•ibobev•1d ago•26 comments

Learning Programming in an Age of LLMs

https://blog.ploeh.dk/2026/09/16/on-learning-programming-in-an-age-of-llms/
208•moneroloop2018•11h ago•160 comments

Reversing Factorio's RNG

https://gegell.github.io/posts/factorio-rng/
7•jheitmann•4d ago•1 comments

The DeepMind Institute

https://institute.deepmind.com/
83•vertigoruntime•5h ago•26 comments

Claude Cowork and chat are now one Claude

https://claude.com/blog/cowork-is-now-claude
155•vertigoruntime•3h ago•175 comments

How good are frontier models at physics?

https://arxiv.org/abs/2609.13009
19•qt31415926•1h ago•3 comments

ER visits for gambling disorders doubled after expanded online gambling market

https://temertymedicine.utoronto.ca/news/emergency-room-visits-gambling-disorders-nearly-doubled-...
116•geox•2h ago•95 comments

The Google Play app review process now regularly takes longer than a week

https://gultsch.social/@daniel/117280438824908947
314•inputmice•9h ago•297 comments

Hackers Got Inside a Flock Camera

https://www.wired.com/story/hackers-flock-camera-data-shows-how-system-works/
376•driverdan•7h ago•184 comments

A coffee shop owner used AI to make a menu poster. Then came the angry DMs

https://www.businessinsider.com/coffee-shop-owner-ai-menu-backlash-2026-9
32•TMWNN•1h ago•68 comments

Show HN: How Stale Is Your AI? Release age and training cutoff for 20 models

https://stale.jock.pl/
61•joozio•7h ago•39 comments

Fed Raises Rates for First Time in Three Years

https://www.wsj.com/economy/central-banking/fed-raises-rates-for-first-time-in-three-years-08539fbe
19•kaycebasques•1h ago•2 comments

Kyber (YC W23) Is Hiring a Forward Deployed Engineer

https://www.ycombinator.com/companies/kyber/jobs/eturrAR-forward-deployed-engineer
1•asontha•8h ago

Why a fast-growing German AI startup is moving its parent company from the US

https://www.euronews.com/business/2026/09/16/why-this-fast-growing-german-ai-start-up-is-moving-i...
24•jethronethro•1h ago•4 comments

Can we stop with the uptime percentages?

https://blog.jim-nielsen.com/2026/stop-with-the-uptime-percentage/
110•surprisetalk•4h ago•90 comments

Salesforce Global Outage

https://status.salesforce.com/products/all
249•mabil•9h ago•153 comments

Show HN: I made a flight simulator, except you're just a passenger

https://inflightsimulator.com
400•rkotcher•2d ago•198 comments

A warning about 'model welfare'

https://mustafa-suleyman.ai/a-warning-about-model-welfare
135•andsoitis•5h ago•328 comments

This Code Is CRAP (2011)

https://testing.googleblog.com/2011/02/this-code-is-crap.html
69•luispa•4h ago•46 comments

Scaling Golang CI by Replacing actions/setup-go

https://www.cloudx.ai/posts/setup-go
62•peterldowns•7h ago•19 comments

Anatomy of a Texture

https://agentlien.github.io/texture/
43•Agentlien•5h ago•8 comments