这句话中可以把TRUNCATE函数去掉,然后把“<= to_date('20030508','yyyymmdd')”改为“<to_date('20030509','yyyymmdd')”;泥还应当把那个视图也贴上来,视图有可能也得优化一下~

解决方案 »

  1.   

    对,水皮皮说得对。Oracle中的Sql语句编写时一定要注意不要对字段进行任何处理,比如你上面就对datatimel字段进行trunc操作,这是不合理的。另外,尽量减少视图的使用。你可以把你的建视图脚本贴上来,如果没什么必要,最好不要用。
      

  2.   

    1.在datetime1上增加索引
    2.去掉trunc,to_date('20030508','yyyymmdd') 改成to_date('20030508','yyyymmdd')+0.99999
      

  3.   

    SELECT distinct col from v_view1
    where datetime1 between to_date('20010101','yyyymmdd') 
      and datetime1 and  to_date('20030508','yyyymmdd')
      and instr(string1,'13302')
      and flag='1';
     
    create index ix_datetime1 on v_view1(datetime1);
    create index ix_flag on v_view1(flag);