indexing - Is there ever a scenario in SQL where an index would be detrimental? -
can index ever hurt? that's whole question. i'm curious.
query optimizers ignore indexes irrelevant query. still have spend microseconds during query optimization, considering whether each index should used.
the more indexes have on table, more complex optimizer's job analyze best 1 use. in rare cases, optimization phase more costly query execution.
i worked on case helping client using mysql 5.6, in new sophisticated query optimization features caused query use 100% cpu during optimization. basically, caused optimizer estimate benefit of thousands of permutations of index choices, chess-playing program looking ahead several moves.
to solve problem, changes configuration variables make mysql 5.6's optimizer skip new features, , dumber optimal index choice, in mysql 5.5. solved cpu spike issue in case.
that case exceptional because query complex, , had many indexes.
this case specific 1 version of 1 brand of rdbms. other brands of database may have similar edge cases.
Comments
Post a Comment