goods表添加索引 (goods_name,store_name,brand_name)
where条件的顺序:123
select * from goods
where goods_name = '商品名称'
and store_name = '店铺名称'
and brand_name = '品牌名称';
用到goods_name,store_name,brand_name
where条件的顺序:132
select * from goods
where goods_name = '商品名称'
and brand_name = '品牌名称'
and store_name = '店铺名称';
用到goods_name,store_name,brand_name
where条件的顺序:213
select * from goods
where store_name = '店铺名称'
and goods_name = '商品名称'
and brand_name = '品牌名称';
用到goods_name,store_name,brand_name
where条件的顺序:231
select * from goods
where store_name = '店铺名称'
and brand_name = '品牌名称'
and goods_name = '商品名称';
用到goods_name,store_name,brand_name
where条件的顺序:312
select * from goods
where brand_name = '品牌名称'
and goods_name = '商品名称'
and store_name = '店铺名称';
用到goods_name,store_name,brand_name
where条件的顺序:321
select * from goods
where brand_name = '品牌名称'
and store_name = '店铺名称'
and goods_name = '商品名称';
用到goods_name,store_name,brand_name
where条件的顺序:12
select * from goods
where goods_name = '商品名称'
and store_name = '店铺名称';
用到goods_name,store_name
where条件的顺序:13
select * from goods
where goods_name = '商品名称'
and brand_name = '品牌名称';
用到goods_name
where条件的顺序:21
select * from goods
where store_name = '店铺名称'
and goods_name = '商品名称';
用到goods_name,store_name
where条件的顺序:23
select * from goods
where store_name = '店铺名称'
and brand_name = '品牌名称';
没有用到
where条件的顺序:31
select * from goods
where brand_name = '品牌名称'
and goods_name = '商品名称';
用到goods_name
where条件的顺序:32
select * from goods
where brand_name = '品牌名称'
and store_name = '店铺名称';
没有用到
where条件的顺序:1
select * from goods
where goods_name = '商品名称';
用到goods_name
where条件的顺序:2
select * from goods
where store_name = '店铺名称';
没有用到
where条件的顺序:3
select * from goods
where brand_name = '品牌名称';
没有用到
使用union
select * from goods where goods_name = '商品名称';
union
select * from goods where store_name = '店铺名称';
union
select * from goods where brand_name = '品牌名称';
用到goods_name
使用or
如果where中包含goods_name = ‘商品名称’,则如下
否则,如下
所有使用到or的情况不会使用到索引(未必,未完待续。。。)