银行索引

db2索引是怎么判断是否走索引的?

在一个100多万行记录的表上的char(1)列C上做了个索引runstats后测试了一下各个语句是否走索引结果发现select * from tabname where C='0' 不会走索引select * from tabname where C != '0' 会走索引用db2expln来看的我认为都应该走索引才对。。。 比较奇怪顺便问一下,例...显示全部
在一个100多万行记录的表上的char(1)列C上做了个索引
runstats后测试了一下各个语句是否走索引

结果发现select * from tabname where C='0' 不会走索引
select * from tabname where C != '0' 会走索引

用db2expln来看的

我认为都应该走索引才对。。。 比较奇怪
顺便问一下,例如select A,B,C from *** where C!='0' 这种类型的语句,在db2advis里面,会建议建立 A,B,C三列的多列索引,这是为什么?我觉得只要在C上建索引就足够了应该收起
参与7

查看其它 3 个回答drdb2的回答

drdb2drdb2系统工程师se
select count(*) from tabname where C='0' returns how many rows?
select count(*) from tabname where C!='0' returns how many rows?
if " C!='0'" contains ton of rows, there is no reason to do index scan
The primary purpose of indexing is to help returning small portion of data.
互联网服务 · 2014-02-05
浏览1565

回答者

drdb2
系统工程师se

drdb2 最近回答过的问题

回答状态

  • 发布时间:2014-02-05
  • 关注会员:1 人
  • 回答浏览:1565
  • X社区推广