一个表tb_01共有50个字段,其中关建字段内容如下:id_shch_b, page_no, gx_int, gongxh, gx_int_q, gx_int_x, gongxh_q, gongxh_x, ......
DA0000001, 1 1 A1 0 3
DA0000001, 1 3 B1 1 4
DA0000001, 1 4 C1 3 6
DA0000001, 1 6 D1 4 8
DA0000001, 1 8 E1 6 0
...
DA0000005, 3 1 A1 0 2
DA0000005, 3 2 A2 1 3
DA0000005, 3 3 A5 2 6
DA0000005, 3 6 A6 3 7
DA0000005, 3 7 B3 6 0
...其中,id_shch_b, page_no, gx_int是主键值。
但常用的查条件会是:
select * from tb_01 where id_shch_b='' and page_no='' and gx_int_q=''
select * from tb_01 where id_shch_b='' and page_no='' and gx_int_x=''
select * from tb_01 where id_shch_b='' and page_no='' and gx_int=''select a.*, b.gongxh
from tb_01 a
left outer join tb_01 b on a.id_shch_b=b.id_shch_b and a.page_no=b.page_no and a.gx_int=b.gx_int_q
where A.id_shch_b='' and A.page_no='' and A.gx_int=''
因为gx_int_q, gx_int_x两个字段,经常参于查询,为了提高查询的速度,请问题应该如何建索引。需要另外建如下两个索引吗?
id_shch_b, page_no, gx_int_x
id_shch_b, page_no, gx_int_q
因为其它查询的需要,现在已经新建了5个索引了,因为索引太多,存盘速度明显变慢。请问应该如何优化索引呢?
如果select经常用到where里某些列的组合查询,建议建立组合索引.
组合索引,按照列的使用频率,按照使用频率设置索引列的先后顺序.
现在的总记录数量:500万笔,每天新增的记录数量是1万笔左右.
并且上面的查询,平均每1分钟都会使用一次.
同时联机用户150个左右.服务器是IBM460的,2G内存,现在有点慢了.所以想优化一下.
id_shch_b, page_no, gx_int_q 的分布情况
前导列索引设置最为重要