1、
   select × 
   from tab
   where substring(id,1,4)= ‘1234’
 如何优化? 2、
   select × 
   from tab
   where kinnum/100 < 1000
 如何优化? 3、说说oracle有哪些优化方案。 以上三道题请各位指教。谢谢!!

解决方案 »

  1.   

    个人愚见:
    没经过测试
    1、在substring上建立函数索引
    2、方法同一
    3、google
      

  2.   

    第二个:
      select ×
      from tab
      where kinnum < 100000
      

  3.   

    star_guan2008哥们!!
    怎么建立在〔substring〕上建立函数索引啊! 
      

  4.   

    这种题,是考你在字段上做运算时,用不上索引。
    1、 
      select × 
      from tab 
      where substring(id,1,4)= ‘1234’ 
    如何优化? 
    改成:
      select x from tab where id like '1234%';
     id字段上当然得有索引2、 
      select × 
      from tab 
      where kinnum/100 < 1000 
    如何优化? 
    改:
     select x from tab where kinum < 100000
      

  5.   

    第一个可以建立函数索引:
    CREATE TABLE TEST
    (
    COL1 VARCHAR2(10),
    COL2 VARCHAR2(10)
    );CREATE INDEX IDX_TEST
    ON TEST(SUBSTR(COL1,1,4))第二个类似的建立索引
      

  6.   

    这种题,是考你在字段上做运算时,用不上索引。 
    1、 
      select × 
      from tab 
      where substring(id,1,4)= ‘1234’ 
    如何优化? 
    改成: 
      select x from tab where id like '1234%'; 
    id字段上当然得有索引 2、 
      select × 
      from tab 
      where kinnum/100 < 1000 
    如何优化? 
    改: 
    select x from tab where kinum < 100000 
    严重同意
      

  7.   

    select × 
      from tab 
      where id like 1234'||'%'
    2、 
      select × 
      from tab 
      where kinnum < 100000
    3、说说oracle有哪些优化方案。这个关系理论太多了
      

  8.   

    1和2
    同意4楼的答案,最后一个问题,仅提供一些参考:
    sql优化方案
    1 使用where 条件减少检索结果的数量
    2 使用表之间的连接而不使用多个查询
    3 执行连接的时候、使用完全限定的列的引用
    4 使用case表达式、而不使用多个查询
    5 添加表的索引
    6 使用where而不是 having
    7 使用union all 而不是 union
    8 使用exist而不是in
    9 使用exist而不是distinct
      

  9.   

    同意2楼与4楼的
    旧的索引对字段进行函数运算是不起效果的,要建函数索引,如果楼主要使用自己写的SQL就要建函数索引;想用回旧的索引就要SQL改为4楼的写法
      

  10.   

    优化方案:
    sql的书写,尽量共享
    sql每个表的连接方式如果可以显式指定,则可以减少解析时间
    ……