|
|
|
|
|
by crazygringo
442 days ago
|
|
Using AI to improve query performance seems inevitable, kind of how LLM's have made ffmpeg so much more usable. There are just so many factors that go into writing a query that will be performant, not just basic indexes but joins vs. subqueries, single-column indexes vs. multi-column indexes with various sort orders, etc. And even if you write something that's performant at 1,000 rows in your test database, it falls apart with 1,000,000 rows in production. But reliable AI that can actually understand all your queries together with the database structure, in order to find performance improvements, feels like it's going to become as helpful on the database side as Copilot etc. is on the regular coding side. |
|
It looks like LLMs can do a pretty good job at generating ideas, particularly if you prompt them right.
After that, you have to: 1/ make sure that the SQL produces the same results, 2/ see what the query planner will actually do with it, 3/ see whether it improves performance.
As you point out, the data makes a difference, so you need production data statistics, at a minimum, to do this well.