UPDATE `study`.`test` SET `aid` = 'a01', `bid` = 'b01', `cid` = 'c01' WHERE `id` = 1;
UPDATE `study`.`test` SET `aid` = 'a02', `bid` = 'b02', `cid` = 'c02' WHERE `id` = 2;
UPDATE `study`.`test` SET `aid` = 'a03', `bid` = 'b02', `cid` = 'c03' WHERE `id` = 3;
组合结果为 abc ab ac bc 四种组合结果
abc 组合结果为
mysql> explain select * from test where aid='a01' and bid='b01' and cid='c01'\G;
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: test
partitions: NULL
type: ref
possible_keys: abc
key: abc
key_len: 186
ref: const,const,const
rows: 1
filtered: 100.00
Extra: Using index
1 row in set, 1 warning (0.00 sec)
ERROR:
No query specified
可能用到复合索引,实际用到复合索引。
ab 的组合结果如下
mysql> explain select * from test where aid='a01' and bid='b01' \G;
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: test
partitions: NULL
type: ref
possible_keys: abc
key: abc
key_len: 124
ref: const,const
rows: 1
filtered: 100.00
Extra: Using index
1 row in set, 1 warning (0.00 sec)
ERROR:
No query specified
可能用到复合索引,实际用到复合索引。
ac 的组合情况下
explain select * from test where aid='a01' and cid='c01'\G;
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: test
partitions: NULL
type: ref
possible_keys: abc
key: abc
key_len: 62
ref: const
rows: 1
filtered: 33.33
Extra: Using where; Using index
1 row in set, 1 warning (0.00 sec)
ERROR:
No query specified
可能用到复合索引,实际用到复合索引。
bc 的组合情况下
explain select * from test where bid='b01' and cid='c01'\G;
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: test
partitions: NULL
type: index
possible_keys: NULL
key: abc
key_len: 186
ref: NULL
rows: 3
filtered: 33.33
Extra: Using where; Using index
1 row in set, 1 warning (0.00 sec)
ERROR:
No query specified
请发表评论