“81% faster query plans than Postgres”…on an 8 GB dataset that fits entirely in memory, with shared_buffers constrained to a fraction of that, queries warmed before measuring, and read-only SELECTs. I would be cautious about over fitting, it’s tough to say if those query plans would really be more optimal than Postgres heuristics at scale and with a bit more realistic OLTP workloads. In any case, such is life with pr…
I think in principle you could clone your database in prod and at least test to see if your most difficult + common queries are indeed faster after running through the LLM optimizer?
Training a 4B model to produce 81% faster query plans than Postgres
111–120 of 129 posts
Re: Training a 4B model to produce 81% faster query plans than Postgres
#112Earlier quoted context omitted.
The immediate problem: How do you know which one is better without running them?
You create formulas to estimate the cost of running a given query plan. Use statistics collected about the tables (e.g. how many rows) to try to be accurate. The topic is "Cost Based Optimization".
Re: Training a 4B model to produce 81% faster query plans than Postgres
#113Earlier quoted context omitted.
With a 4B parameter model that probably ran through 8GBs of RAM multiple times to run. At a certain point we should seriously talk about CUDA accelerating Postgres instead.
pardon but aren't disks usually the bottleneck? im all for CUDA acceleration and CUDA accelerating culture
Re: Training a 4B model to produce 81% faster query plans than Postgres
#114Earlier quoted context omitted.
What would you accelerate? Is there a lot of linear algebra you could throw cuda at in Postgres?
You know that GPUs are more flexible than just linear algebra, right? GPUs are simply faster at fundamental algorithms like sorting (which has huge parallelism), and hashing. This is because both sorting and hashing benefit from endless growth of parallelism, offering enough "work" for these 10,000 SIMD-core systems to crunch work upon. And because of modern algorithms/libraries with 'Mergepath sort' (a GPU-SIMD para…
Re: Training a 4B model to produce 81% faster query plans than Postgres
#115Unless they’ve been elided, there were no indices other than the PK on any table, and no additional statistics. There are correlated columns here: a given country may have produced more movies in a given range of years, as its movie industry built up; a given country may produce more TV series than movies, etc. Nearly every time I’ve seen someone resorting to hints for a query, it’s because their statistics are incor…
Re: Training a 4B model to produce 81% faster query plans than Postgres
#116Earlier quoted context omitted.
The immediate problem: How do you know which one is better without running them?
Could you A/B at random, use that to collect data and eventually feed that back in to prefer A or B depending on the shape of the query?
Re: Training a 4B model to produce 81% faster query plans than Postgres
#117Engineer: "HELP, our production DB is frozen on this query that worked fine before!" 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?"
Re: Training a 4B model to produce 81% faster query plans than Postgres
#118Earlier quoted context omitted.
What if we use a hybrid model of using both query optimizer and LLM? Whichever produces better result, the database can use? - a question from someone with lack of DB depth, me.
This is about to bake your noodle: https://www.postgresql.org/docs/current/geqo-pg-intro.html
Re: Training a 4B model to produce 81% faster query plans than Postgres
#119“81% faster query plans than Postgres”…on an 8 GB dataset that fits entirely in memory, with shared_buffers constrained to a fraction of that, queries warmed before measuring, and read-only SELECTs. I would be cautious about over fitting, it’s tough to say if those query plans would really be more optimal than Postgres heuristics at scale and with a bit more realistic OLTP workloads. In any case, such is life with pr…
I think in principle you could clone your database in prod and at least test to see if your most difficult + common queries are indeed faster after running through the LLM optimizer?
That is the responsibility of whoever thought it would be a good idea to write this article. It's their responsibility to show that their idea has merit, and that their results are significant. I mean, don't they have a vested interest in manipulating and cherry-picking their results to inflate their relevance?
This is why academic papers are peer reviewed.
Re: Training a 4B model to produce 81% faster query plans than Postgres
#120Earlier quoted context omitted.
That bug is fixable and verifiable. The LLM you cross your fingers till the next time the same thing happens.
> fixable and verifiable 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, et…