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
It is not compulsory to remove individual index for adding composite index, based on requirement either you can keep or drop it/them.
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.