TIL MySQL 8 Invisible Indexes

TIL about MySQL 8’s invisible indexes. They make it possible to test the effect of removing an index on query performance, without making a destructive change. When an index is invisible, the query optimizer won’t use it.

Change an index’s visibility like this:

ALTER TABLE my_table ALTER INDEX some_index INVISIBLE;
ALTER TABLE my_table ALTER INDEX some_index VISIBLE;

Pretty cool!

There’s more info and details in the docs, so be sure to check them out.

Tagged til mysql