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.
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.
should become
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