Is normal MySql index required when we have Composite index

前端 未结 2 1680
旧时难觅i
旧时难觅i 2021-01-23 11:20

We have MySql table having 25 million rows

Following are the columns in table

c_id,c_name,s_id,l_type,l_time,message,domain

among above

相关标签:
2条回答
  • 2021-01-23 12:05

    It is not compulsory to remove individual index for adding composite index, based on requirement either you can keep or drop it/them.

    0 讨论(0)
  • 2021-01-23 12:11

    Any prefix of a composite index will be used as an index by itself as well. So if you have a composite index on (domain, log_time, log_type), it's equivalent to having indexes on domain and (domain, log_time). There's no need to have these indexes separately as well, they will be redundant and waste space.

    So you can safely remove the index on domain when you add this composite index.

    0 讨论(0)
提交回复
热议问题