1.先看一下不加索引的情况
2.然后添加组合索引
ALTER TABLE table_name ADD INDEX index_name (`field_1`,`field_2`);
explain select * from table_name where field_1=1 and field_2=1
看到涉及到的行数变为了22
3.删掉组合索引
alter table table_naem drop index enable_xxx
添加两个单独索引
ALTER TABLE user_portrait_crm_tag ADD INDEX index_1 (`index_1`);
ALTER TABLE user_portrait_crm_tag ADD INDEX index_2 (`index_2`);
再次执行
explain select * from table_name where field_1=1 and field_2=1
看到rows变为了29