0
我有兩個字段用於搜索表格:field1,field2。它們並非通過所有記錄都是唯一的,既不是單獨的也不是組合的MySQL索引:索引2個字段的方式有什麼區別?
他們所以我添加索引:
方法之一:
alter table xx add index (field1, field2);
alter table xx add index (field2);
方法有兩個:
alter table xx add index (field1);
alter table xx add index (field2);
我的問題是什麼這兩個方法之間的差異,如果任何?對於以下每個選擇查詢:
select * from table xx where field1 = ??
select * from table xx where field2 = ??
select * from table xx where field1 = ?? and field2 = ??
select * from table xx where field1 = ?? or field2 = ??
哪種方法更好?
而且,對於此查詢,哪種方法更好?
select * from table xx where field1 = ?? and field2 = ??