select * from device d join boiler b ON d.device_id = b.boiler_id 
 where d.deleteRe = 0 and b.power >= 1 select * from device d join boiler b ON d.device_id = b.boiler_id 
 where d.deleteRe = 0 and b.power >= 1 and b.power<= 99992条语句结果是一样多的记录,但是默认的执行计划(没有给出任何优化设置)不同,device ,boiler 通过  device_id = boiler_id 一对一关联,deleteRe 删除标记,
我们看到是数字的在数据库里都是Number型(可能是小数,如果是小数都指定了小数位数)。
执行计划可以看这个帖子: 
http://community.csdn.net/Expert/topic/4585/4585087.xml?temp=.1323816

解决方案 »

  1.   

    1. 你都指定了它们的优化模式没有?比如都是/*+ first_rows*/
    2. 表分析没有,还要分析索引和索引列.
    这些都有了,再比较执行计划不同,
      

  2.   

    你建了个bitmap index?要不直接用提示指定用哪个索引.
      

  3.   

    目前没有设置任何优化模式,我应该怎么选择呢?
    Device 表每年约 40 万条, Boiler = Device/8 (一共有8种设备)
    我每次只取 20 条,我该用什么 优化模式? 还有如何 分析 ? bitMap 怎么建,现在好像没有创建, PL/SQL Developer 给出的 计划
    也不知道哪儿来的 bitMap ,这是默认的么?
      

  4.   

    用什么 优化模式? 
    --------
    用first_rows还有如何 分析
    -----------
    SQL> analyze table t compute statistics for table for all indexes for all indexed columns; bitMap
    -----------
    我看计划已经用了bitmap index,那肯定是谁建的.
      

  5.   

    这个  Analyze 语句需要隔一段时间执行一次吧?
    然后在我的 SQL 中插入 /*+ first_rows*/ ( 只取 20 行就用这个 )是这样就差不多了吧?还有别的要注意的么?
      

  6.   

    Analyze不要频繁执行,很消耗资源的,比如你大量增加,修改和删除数据,再用.
    其它没什么