Ignored Indexes
Ignored indexes allow indexes to be visible and maintained without being used by the optimizer. This feature is comparable to MySQL 8’s "invisible indexes."
Ignored indexes are indexes that are visible and maintained, but which are not used by the optimizer. MySQL 8 has a similar feature which they call "invisible indexes".
Syntax
By default, an index is not ignored. One can mark existing index as ignored (or not ignored) with an ALTER TABLE statement:
ALTER TABLE table_name ALTER {KEY|INDEX} [IF EXISTS] key_name [NOT] IGNORED;It is also possible to specify IGNORED attribute when creating an index with a CREATE TABLE, or CREATE INDEX statement:
CREATE TABLE table_name (
...
INDEX index_name ( ...) [NOT] IGNORED
...CREATE INDEX index_name (...) [NOT] IGNORED ON tbl_name (...);table's primary key cannot be ignored. This applies to both explicitly defined primary key, as well as implicit primary key - if there is no explicit primary key defined but the table has a unique key containing only NOT NULL columns, the first of such keys becomes the implicitly defined primary key.
Handling for ignored indexes
The optimizer will treats ignored indexes as if they didn't exist. They will not be used in the query plans, or as a source of statistical information.
Also, an attempt to use an ignored index in a USE INDEX, FORCE INDEX, or IGNORE INDEX hint will result in an error - the same what would have if one used a name of a non-existent index.
Information about whether or not indexes are ignored can be viewed in the IGNORED column in the Information Schema STATISTICS table or the SHOW INDEX statement.
Intended Usage
The primary use case is as follows: a DBA sees an index that seems to have little or no usage and considers whether to remove it. Dropping the index is a risk as it may still be needed in a few cases. For example, the optimizer may rely on the estimates provided by the index without using the index in query plans. If dropping an index causes an issue, it will take a while to re-create the index. On the other hand, marking the index as ignored (or not ignored) is instant, so the suggested workflow is:
Mark the index as ignored
Check if everything continues to work
If not, mark the index as not ignored.
If everything continues to work, one can safely drop the index.
Examples
The optimizer does not make use of an index when it is ignored, while if the index is not ignored (the default), the optimizer will consider it in the optimizer plan, as shown in the EXPLAIN output.
This page is licensed: CC BY-SA / Gnu FDL
Last updated
Was this helpful?

