- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
5#
发表于 2012-5-4 21:10:18
ODM TEST:
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
SQL> -- Create table
SQL> create table T_PART_INTER
2 (
3 ID NUMBER,
4 NAME VARCHAR2(30),
5 CREATE_DATE DATE
6 )
7 partition by range (CREATE_DATE)
8 (
9 partition P1 values less than (TO_DATE(' 2009-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
10 tablespace USERS
11 pctfree 10
12 initrans 1
13 maxtrans 255,
14 partition P2 values less than (TO_DATE(' 2009-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
15 tablespace USERS
16 pctfree 10
17 initrans 1
18 maxtrans 255,
19 partition P3 values less than (TO_DATE(' 2009-07-30 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
20 tablespace USERS
21 pctfree 10
22 initrans 1
23 maxtrans 255
24 storage
25 (
26 initial 8M
27 next 1M
28 minextents 1
29 maxextents unlimited
30 ),
31 partition P4 values less than (TO_DATE(' 2009-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
32 tablespace USERS
33 pctfree 10
34 initrans 1
35 maxtrans 255
36 storage
37 (
38 initial 8M
39 next 1M
40 minextents 1
41 maxextents unlimited
42 )
43 );
Table created.
SQL> insert into t_part_inter values(1,'TEST',to_date('20080101','yyyymmdd'));
1 row created.
SQL> commit;
Commit complete.
SQL> select rowid from t_part_inter;
ROWID
------------------
AAATy3AAEAAAmwlAAA
SQL>
SQL> select distinct sid from v$mystat;
SID
----------
125
SQL> exec dbms_stats.gather_table_stats('','T_PART_INTER');
PL/SQL procedure successfully completed.
SQL> set linesize 200 pagesize 1400
SQL>
SQL> set autotrace on;
SQL> update t_part_inter set create_date=to_date('20080102','yyyymmdd') where rowid='AAATy3AAEAAAmwlAAA';
1 row updated.
Execution Plan
----------------------------------------------------------
Plan hash value: 1812390831
------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
------------------------------------------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 1 | 16 | 1 (0)| 00:00:01 | | |
| 1 | UPDATE | T_PART_INTER | | | | | | |
| 2 | TABLE ACCESS BY USER ROWID| T_PART_INTER | 1 | 16 | 1 (0)| 00:00:01 | ROWID | ROWID |
------------------------------------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
1 recursive calls
2 db block gets
0 consistent gets
0 physical reads
452 redo size
833 bytes sent via SQL*Net to client
861 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> commit;
Commit complete.
SQL> update t_part_inter set create_date=to_date('20090102','yyyymmdd') where rowid='AAATy3AAEAAAmwlAAA';
1 row updated.
Execution Plan
----------------------------------------------------------
Plan hash value: 1812390831
------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
------------------------------------------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 1 | 16 | 1 (0)| 00:00:01 | | |
| 1 | UPDATE | T_PART_INTER | | | | | | |
| 2 | TABLE ACCESS BY USER ROWID| T_PART_INTER | 1 | 16 | 1 (0)| 00:00:01 | ROWID | ROWID |
------------------------------------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
32 recursive calls
46 db block gets
7 consistent gets
3 physical reads
3368 redo size
834 bytes sent via SQL*Net to client
861 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> select cpu_time,elapsed_time,BUFFER_GETS,sql_text from v$sql where sql_text like '%AAATy3AAEAAAmwlAAA%' and sql_text not like '%like%' and sql_text not like '%EXPLAIN%';
CPU_TIME ELAPSED_TIME BUFFER_GETS
---------- ------------ -----------
SQL_TEXT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1000 1580 2
update t_part_inter set create_date=to_date('20080102','yyyymmdd') where rowid='AAATy3AAEAAAmwlAAA'
2000 2688 53
update t_part_inter set create_date=to_date('20090102','yyyymmdd') where rowid='AAATy3AAEAAAmwlAAA'
update partition key :
1. 没有造成 row movement 的 cpu time = 1000 BUFFER_GETS =2
2. 造成 row movement 的 cpu time=2000 BUFFER_GETS=53
比起普通的update 而言 造成row movement的update partition key 的性能消耗是 巨大的, 在OLTP 环境中应当避免 频繁的 更新 update partition key 造成row movement 。 |
|