shatteredsilicon / ssm-submodules

GNU Affero General Public License v3.0
1 stars 2 forks source link

Add Query / Indexing Advisor Functionality to QAN #123

Open gordan-bobic opened 1 year ago

gordan-bobic commented 1 year ago

What we ideally want for each query is two things:

1) ALTER TABLE / CREATE INDEX statements to create hypothetical indexes that might make the query faster

2) Modifications to the query that might make it faster. For exmaple: 2.1) Replacing sub-SELECTs with JOINs 2.2) Doing away with use of functions on columns, e.g.

WHERE DATE(created_at) = 2023-01-10

should become

WHERE created_at >= '2023-01-10' AND created_at < '2023-01-11'

Of the advisor cannot see any obvious way to improve on the existing indexes or query form, it should return a comment saying it cannot find any way to improve the query further.

There some open source tools that do similar things, but they are PostgreSQL specific and not quite what we want: https://github.com/cohenjo/pg_idx_advisor https://github.com/DrPostgres/pg_adviser

gordan-bobic commented 7 months ago

Moved this to .5 because I have some ideas about this. To be discussed internally.