Training a 4B model to produce 81% faster query plans than Postgres
Thread
Unofficial Hacker News client; not affiliated with Y Combinator.
Training a 4B model to produce 81% faster query plans than Postgres
Unofficial Hacker News client; not affiliated with Y Combinator.
2001zhaozhao · · focus · HN ↗
Infra: "Hmm, let's check... Well would you look at that, it seems like your LLM query planner usually works and produces fast queries, but this time when you changed a variable name to trigger query rebuild, it happened to hallucinate and miss an index, would you mind re-running the LLM a few times until you get a faster query?"
malisper · · focus · HN ↗
[deleted] · · focus · HN ↗
[deleted]
Tanjreeve · · focus · HN ↗
egeozcan · · focus · HN ↗
By people with a specific skill set. LLMs generation can also be fixed and verified by people with a certain skill set, and non-deterministic computing doesn't automatically mean unpredictable. When people say that the LLMs are a black box, it means unpredictability in unknown situations.
You do structured output, input validation, output validation, lower temperature, limit decisions, RL, etc. to increase predictability to near certainty. It's just statistics after all. Or you can as well generate the code to do the job.
It's just that the required skill set is a different one to do those things, and unusual in the context of DB administration.
Tanjreeve · · focus · HN ↗
egeozcan · · focus · HN ↗
I just find the "all llms are non dererministic and therefore unreliable" narrative a bit backwards. All software that has more than 0 users needs to deal with non-determinism anyway :)
tempfile · · focus · HN ↗
malisper · · focus · HN ↗
Tanjreeve · · focus · HN ↗
egeozcan · · focus · HN ↗
From a completely technical perspective, we have a rough idea how the LLMs work, and improving a system requires measuring outcomes and you don't necessarily need to understand the mechanism.
EXPLAIN ANALYZE against data that's similar in size to prod checks a query written by an LLM as good as anything we can write... but, yes, you're right, we still didn't solve the halting problem - neither the LLMs.
d0100 · · focus · HN ↗
Query planner feels pretty LLM-esque already
Tanjreeve · · focus · HN ↗
malisper · · focus · HN ↗
A bad query plan is not your typical kind of bug. I would definitely not call it fixable. Query planners are inherently dealing with estimations and approximations. If the query planners estimation is off, you're screwed.
Unless you come up with a way to cheaply determine exactly how many rows a query will return, bad query plans will still exist.
danielbarla · · focus · HN ↗
I've literally been saying "I can't believe the date is X and we still have to put up with this" for around 25 years now.
galkk · · focus · HN ↗
reval · · focus · HN ↗
simondotau · · focus · HN ↗
mr_toad · · focus · HN ↗
simondotau · · focus · HN ↗
ants_a · · focus · HN ↗
Stored procedures in this context are just a clumsy workaround to control the planner so your comment about API layer is irrelevant. But if you like, you can write stored procedures in a ton of different languages. And if you do not have source control for your database artifacts, you are doing it wrong. A common reason for stored procedures is to not have a bunch network roundtrips in the middle of your transaction logic while you are holding onto locks / have an open conflict window.
simondotau · · focus · HN ↗
Stored procedures are essentially a crude, database-bound API layer. For serious application development, a proper service layer provides stronger contracts, authentication, testing, versioning, observability and source control in a sane general-purpose language, ideally the same one you’re already manipulating the data with elsewhere.
ants_a · · focus · HN ↗
I guess we agree on them being an API that gets deployed on the database, but I disagree that it needs to be crude. It's exactly as crude as you make it. If you don't have authentication, testing, versioning, observability and source control for your database you are doing it wrong.
twellborn · · focus · HN ↗
[dead]
[deleted] · · focus · HN ↗
[deleted]
ehe78qhe · · focus · HN ↗
websap · · focus · HN ↗
ehe78qhe · · focus · HN ↗
wodenokoto · · focus · HN ↗