|
|
|
|
|
by Someone
1450 days ago
|
|
It’s like writing a compiler or interpreter: writing one is easy; writing a good one extremely hard. This suggester isn’t very good. It takes a single query and suggests indexes for it. A good one would take a mix of queries and suggest a set of indexes, also considering the impact on write speed of additional indexes (table updates often need to update indexes, too) For the example in this article, if the table is large and the average number of rows with a given ‘a’ value is close to 1 or if most queries are for ‘a’ values that aren’t in the database, it may even be better to do CREATE INDEX x1a ON x1(a);
That gives you a smaller index, decreasing disk usage. |
|
Since we wrote our initial index suggestion tool for Postgres, we actually went back to the drawing board, examined the concerns brought up, and developed a new per-table Index Advisor for Postgres that we recently released [1].
The gist of it: Instead of looking at the "perfect" index for each query, its important to test out different "good enough" indexes that cover multiple queries. Additionally, as you note, the write overhead of indexes needs to be considered (both from a table writes / second approach, as well as disk space used at a given moment in time).
I think this is a fascinating field and there is lots more work to be done. I've also found the 2020 paper "Experimental Evaluation of Index Selection Algorithms" [2] pretty useful, that compares a few different approaches.
[1] https://pganalyze.com/blog/automatic-indexing-system-postgre...
[2] https://www.vldb.org/pvldb/vol13/p2382-kossmann.pdf