DBA真是种神奇的职业

来源:互联网 发布:free mobile java中国 编辑:程序博客网 时间:2024/05/22 15:33

部门里有一个项目遇到了问题,让我帮忙解决一下,问题很简单

select r.flowsn  from ratifylog r,       (select distinct f.flowsn from flowlog f where f.stepname = '政务大厅预收件' and f.status = 'E' and f.flowsn not in (select f.flowsn from flowlog f where f.stepname = '正式受理/一次告知')) a where r.flowsn = a.flowsn   and r.actionresult in ('2', '3');


这是一个统计报表中的一段,其中对应的两个log表数据量都在数十万左右,对应的flowsn、stepname等字段也都创建了normal索引

可是查询这条sql语句用时都在60秒以上,这显然不科学……

 

折腾了很久,其中过程也没啥好说的,最终

drop index INDEX_STEPNAME;create index INDEX_STEPNAME on FLOWLOG (STEPNAME)  tablespace STYDBP  pctfree 10  initrans 2  maxtrans 255  storage  (    initial 64K   --原来这个是5M    minextents 1    maxextents unlimited  );


 

这么折腾之后,查询时间居然变成了0.8秒,这不科学……,度娘告诉我initial只是索引的初始大小空间而已……

 

更神奇的在后头

drop index INDEX_STEPNAME;create index INDEX_STEPNAME on FLOWLOG (STEPNAME)  tablespace STYDBP  pctfree 10  initrans 2  maxtrans 255  storage  (    initial 5M   --重新改回5M    minextents 1    maxextents unlimited  );

查询时间还是保持在0.8秒……,看来真的是如我所想,initial只是索引的初始大小空间而已……,是不会影响sql查询效率的

可是,之前那个60秒的查询是啥回事???

除了刚才那个initial,我没有改任何索引,任何sql,没有调整分区,没有改表空间,神马都没有做!

dba真是个神奇的职业!