Slide 15
Slide 15 text
[12c] DDL deferred invalidation
• From 12cR2, Oracle avoids (or postpones) shared cursor invalidation if possible
e.g.) alter table xxx truncate partition yyy update global indexes deferred invalidation
15
12c update
*Evaluation
• Range-partitioned “Sales” table with local/global index (FTS, Index range scan)
• Partition truncate with/without deferred invalidation option (update global indexes)
• Check v$sql’s invalidation, last_load_time (last hard parse time)
CREATE TABLE scott.sales
( prod_id NUMBER(6)
, cust_id NUMBER
, time_id DATE
, channel_id CHAR(1)
, promo_id NUMBER(6)
, quantity_sold NUMBER(3)
, amount_sold NUMBER(10,2)
)
PARTITION BY RANGE (time_id)
( PARTITION sales_q1_2006 VALUES LESS THAN (TO_DATE('20060401','YYYYMMDD'))
, PARTITION sales_q2_2006 VALUES LESS THAN (TO_DATE('20060701','YYYYMMDD'))
, PARTITION sales_q3_2006 VALUES LESS THAN (TO_DATE('20061001','YYYYMMDD'))
, PARTITION sales_q4_2006 VALUES LESS THAN (TO_DATE('20061201','YYYYMMDD'))
);
insert into scott.sales values(1,1,to_date('20060101','YYYYMMDD'),'1',1,1,1);
insert into scott.sales values(2,1,to_date('20060401','YYYYMMDD'),'1',1,1,1);
insert into scott.sales values(3,1,to_date('20060701','YYYYMMDD'),'1',1,1,1);
insert into scott.sales values(4,1,to_date('20061001','YYYYMMDD'),'1',1,1,1);
commit;
create index scott.amount_sold_ix on scott.sales(amount_sold);
create index scott.prod_id_ix on scott.sales(prod_id) local;
SQL> select /* trunctest01 */ * from scott.sales;
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%
--------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 328 | 25256 | 2
| 1 | PARTITION RANGE ALL | | 328 | 25256 | 2
| 2 | TABLE ACCESS STORAGE FULL| SALES | 328 | 25256 | 2
--------------------------------------------------------------------
SQL> select /* trunctest01 */ * from scott.sales where prod_id>0;
--------------------------------------------------------------------
| Id | Operation | Name | Ro
--------------------------------------------------------------------
| 0 | SELECT STATEMENT | |
| 1 | PARTITION RANGE ALL | |
| 2 | TABLE ACCESS BY LOCAL INDEX ROWID BATCHED| SALES |
|* 3 | INDEX RANGE SCAN | PROD_ID_IX |
--------------------------------------------------------------------
SQL> select /* trunctest01 */ * from scott.sales where amount_sold>0
--------------------------------------------------------------------
| Id | Operation | Name
--------------------------------------------------------------------
| 0 | SELECT STATEMENT |
| 1 | TABLE ACCESS BY GLOBAL INDEX ROWID BATCHED| SALES
|* 2 | INDEX RANGE SCAN | AMOUNT_SOLD_IX
--------------------------------------------------------------------
Local index
Global index