Can creating an index use existing indexes?

I have separate indexes, for example, in columns A, B and C. I would like to create a composite index for the three columns A + B + C.

What impact will my existing indexes have on the composite index creation ? Will the database use them, it doesn’t matter, or will it slow down the creation of my new composite index?

I am using MySql 5.1.

EDIT : By the way, the table has several million rows.

EDIT 2 : thanks to tster for the suggestion: I tried this on a much smaller table (admittedly only 20,000 rows), but even so, creating a new composite index increased noticeably when individual indexes were already present.

+3
source share
2 answers

MySQL usually restores the entire table when adding an index, so all existing ones are also restored. It can be slow.

The only exception is adding an index using the InnoDB plugin, which does not.

As far as I know, it always performs a full table scan when creating an index, however it should do an index scan if you added an index that had the same (or a subset) of columns as another index. Such indexes are usually useful if the columns are in a different order.

Using mysql stock, the more indexes you have, the slower the new one will be, as it will also restore existing indexes.

With the plugin, I think it does not matter.

, , -- .

+6

. - , , .

(: MySQL.)

0

Source: https://habr.com/ru/post/1723845/


All Articles