本帖最后由 learnonedelisonedel 于 2009-08-03 22:58:29 编辑

解决方案 »

  1.   

    select a,b,c,d
    from  (select a, b, c, d 
           from tablename
           where rownum <= :v_index + 10)
    where rownum >= :v_index;select * 不走索引。
      

  2.   

    对于问题一
    select a,b,c,d from
                   ( select a,b,c,d,rownum rn from
                                (select a,b,c,d from table)
                   )
                   where rn>=:index
    感觉多写了一层
    可以写成
    select a,b,c,d from
                   ( select a,b,c,d,rownum rn from table
                   )
                   where rn>=:index
    这里是走索引还是走fts的话,优化器会决策,不过基本上是应该是fts叻问题二。
    select *对执行计划是没有影响的,只是由于*是retrieve所有的字段,所以会传输所有的字段到client,这样在network上是有影响的,这里可以做以下测试
    SQL>set autotr on;
    SQL> select * from user_tables;
    Statistics
    ----------------------------------------------------------
              0  recursive calls
              0  db block gets
             71  consistent gets
              0  physical reads
              0  redo size
           3215  bytes sent via SQL*Net to client
            503  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              5  rows processed
    SQL> select table_name from user_tables;TABLE_NAME
    --------------------------------------------------------------------------------
    STUDENTS
    T1
    T1_111
    TBLUSER
    TESTTAB
    Statistics
    ----------------------------------------------------------
              7  recursive calls
              0  db block gets
             73  consistent gets
              0  physical reads
              0  redo size
            460  bytes sent via SQL*Net to client
            503  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              5  rows processed这里基本上的统计图是相差不大的,除了bytes sent via SQL*Net to client
      

  3.   

    红色那个只是针对无谓语的情况走full table scan。
    如果存在谓语,就有可能走索引!
      

  4.   

    针对*的问题oracle在分析sql语句时,如果看到查询的目标包括*,首先会根据表名,将*转化为列名!
    所以建议LZ写sql语句时,还是写列名吧,为了速度,也为了以后万一需要更改表结构时,可以不修改你的sql语句