有一张数据表,上生产后数据量是千万级的,目前我在开发机上测试里面存储的也有上百万的数据
字段有119个,这是张数据源表,我从里面取数据的时候每次select操作特耗时,因此我在
该表的一个字段上建了索引(data_date 字段类型varchar2(10) ),但是索引建好以后始终没有生效,删除重建以及rebuild
也不行
-----做了如下的分析也是不行
drop index IDX_ETB_DDATE1 ;
analyze table dwh_etb_monthly compute statistics ;
analyze table dwh_etb_monthly compute statistics for all indexed columns;
analyze table dwh_etb_monthly compute statistics for table for all indexes for all indexed columns;
create index idx_dwh_ddate on dwh_etb_monthly(data_date)
-----然后我做查询的语句是:
select * from dwh_etb_monthly t where t.data_date = '2011-03-31'
执行计划是SELECT STATEMENT, GOAL = ALL_ROWS Cost=14060 Cardinality=273095 Bytes=108418715
 TABLE ACCESS FULL Object owner=DATACORE Object name=DWH_ETB_MONTHLY Cost=14060 Cardinality=273095 Bytes=108418715

解决方案 »

  1.   

    ----在贴一下详细的执行计划
    SQL> select * from dwh_etb_monthly t where t.data_date = '2011-03-31';已选择253619行。
    执行计划
    ----------------------------------------------------------
    Plan hash value: 1519047794-------------------------------------------------------------------------------------| Id  | Operation         | Name            | Rows  | Bytes | Cost (%CPU)| Time
        |-------------------------------------------------------------------------------------|   0 | SELECT STATEMENT  |                 |   273K|   103M| 14060   (1)| 00:02:49 ||*  1 |  TABLE ACCESS FULL| DWH_ETB_MONTHLY |   273K|   103M| 14060   (1)| 00:02:49 |-------------------------------------------------------------------------------------
    Predicate Information (identified by operation id):
    ---------------------------------------------------   1 - filter("T"."DATA_DATE"='2011-03-31')
    统计信息
    ----------------------------------------------------------
              1  recursive calls
              0  db block gets
          67033  consistent gets
          51218  physical reads
              0  redo size
       42214108  bytes sent via SQL*Net to client
         186393  bytes received via SQL*Net from client
          16909  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
         253619  rows processed
      

  2.   

    索引字段的数据占到总数据量的25%以上Oracle会自动全表扫描了,如果你一定要走索引的话,可以加一下hint:
    select /*+index(idx_dwh_ddate)*/ * from dwh_etb_monthly t where t.data_date = '2011-03-31'
      

  3.   

    '索引字段的数据占到总数据量的25%以上Oracle会自动全表扫描了' 可能是这个原因了,加了强制执行索引还是全表扫描操作.
      

  4.   


    --强制索引语法没写对
    select /*+ index(t,idx_dwh_ddate) */ 
           t.* 
      from dwh_etb_monthly t 
     where t.data_date = '2011-03-31'--另外如果这个表dml操作不多的话建一个 bit map 索引试试
    create bit map index index_name on dwh_etb_monthly(data_date);