Displaying entries of an index (MYSQL)

Viewed 18

I am trying to list all the entries of an index. Let's say I have unique index_idx on 2 columns (col_1, col_2) on table table_test. I assume that the uniqueness for a tuple is checked by concatenating the values in column col1 and col2 and checking if overall the value is unique. But is there any method predefined using which we can list all the entries for index index_idx.

I saw a similar question here. But the answer didn't make much sense to me. What exactly is ''INDEX COLUMNS LIST' here?

1 Answers

There's no way directly to list the contents of an index (the MySQL / MariaDB developers may have a way to dump index contents, but if they do it's for debugging purposes).

SELECT col_1, col_2 FROM table_test gets you the contents of the index. The index you mentioned is a so-called covering index for that query. MySQL uses the index, rather than the table, to satisfy the query. That's a little faster.

The item you linked does this same thing.

And you are basically correct that the uniqueness of a two-column UNIQUE index is determined with the concatenation of the column values.

Related