select * from table where field is null 需要近5秒钟 其中where后面的field类型为datetime,且是索引列但是用select * from table where field is not null却很快表的记录只有2w条而已十分不解 请高手指点

解决方案 »

  1.   

    oracle中的index是不包含null值的,也就是field is null的时候无法使用index。所以慢。
    而is not null可以使用index。
      

  2.   

    由于B*Tree索引不存储Null值,所以在索引字段允许为空的情况下,某些Oracle查询不会使用索引.
      

  3.   

    无法使用索引,但是此字段又必须使用null来过滤,有没有什么其他的方法来提高检索速度呢谢谢大家了
      

  4.   

    有了null系统就将不再使用索引,可以考虑建个函数索引来用:   
    create index idx_id on your_table (decode(a.id,null,1,2))