计划选择查询,数据加载在oracle中执行缓慢

时间:2015-01-15 09:07:17

标签: sql oracle oracle11g query-tuning

数据库 - Oracle 11g

我们有一张表TB_ETD_NON_MKTS_TRANS_OP,有3000万条记录

我们在REPORTING_PARTY,REPORTING_TIMESTAMP上有索引。

我们正在执行查询

SELECT *
FROM
(select 
  COUNT(*) OVER () CNT,
  ROW_NUMBER() OVER (ORDER BY REPORTING_TIMESTAMP DESC NULLS LAST) RN,
  OP.* 
from TB_ETD_NON_MKTS_TRANS_OP OP 
WHERE REPORTING_PARTY = 'SB'
AND REPORTING_TIMESTAMP >= TO_DATE('11-JAN-2015','DD-MON-YYYY')
AND REPORTING_TIMESTAMP <= TO_DATE('14-JAN-2015','DD-MON-YYYY')
)
WHERE RN >= '1'
AND RN   <= '20';

解释计划输出如下

--------------------------------------------------------------------------------------------------------
| Id  | Operation           | Name                     | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT    |                          |  1726K|   502G|       |   362K  (1)| 01:12:36 |
|*  1 |  VIEW               |                          |  1726K|   502G|       |   362K  (1)| 01:12:36 |
|   2 |   WINDOW SORT       |                          |  1726K|  1330M|  1926M|   362K  (1)| 01:12:36 |
|*  3 |    TABLE ACCESS FULL| TB_ETD_NON_MKTS_TRANS_OP |  1726K|  1330M|       | 69286   (2)| 00:13:52 |
--------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter("RN">=1 AND "RN"<=20)
   3 - filter("REPORTING_TIMESTAMP">=TO_DATE(' 2015-01-11 00:00:00', 'syyyy-mm-dd hh24:mi:ss') 
              AND "REPORTING_PARTY"='SOB' AND "REPORTING_TIMESTAMP"<=TO_DATE(' 2015-01-14 00:00:00', 
              'syyyy-mm-dd hh24:mi:ss'))

0 个答案:

没有答案