- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
2#
发表于 2012-6-24 12:38:50
ODM TEST:- SQL>
- 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> show parameter db_keep
- NAME TYPE VALUE
- ------------------------------------ -------------------------------- ------------------------------
- db_keep_cache_size big integer 128M
- SQL> create table maclean_tan2 storage(buffer_pool keep) as select level id ,rpad('*',4000,'*') data from dual connect by
- 2 level<=15000;
- Table created.
- SQL> select count(*) from maclean_tan2;
- COUNT(*)
- ----------
- 15000
- Execution Plan
- ----------------------------------------------------------
- Plan hash value: 1229461046
- ---------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Cost (%CPU)| Time |
- ---------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | 1 | 4069 (1)| 00:00:49 |
- | 1 | SORT AGGREGATE | | 1 | | |
- | 2 | TABLE ACCESS FULL| MACLEAN_TAN2 | 15476 | 4069 (1)| 00:00:49 |
- ---------------------------------------------------------------------------
- Note
- -----
- - dynamic sampling used for this statement (level=2)
- Statistics
- ----------------------------------------------------------
- 4 recursive calls
- 0 db block gets
- 15081 consistent gets
- 15000 physical reads
- 0 redo size
- 527 bytes sent via SQL*Net to client
- 523 bytes received via SQL*Net from client
- 2 SQL*Net roundtrips to/from client
- 0 sorts (memory)
- 0 sorts (disk)
- 1 rows processed
-
-
- SQL> select count(*) from maclean_tan2;
- COUNT(*)
- ----------
- 15000
- Execution Plan
- ----------------------------------------------------------
- Plan hash value: 1229461046
- ---------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Cost (%CPU)| Time |
- ---------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | 1 | 4069 (1)| 00:00:49 |
- | 1 | SORT AGGREGATE | | 1 | | |
- | 2 | TABLE ACCESS FULL| MACLEAN_TAN2 | 15476 | 4069 (1)| 00:00:49 |
- ---------------------------------------------------------------------------
- Note
- -----
- - dynamic sampling used for this statement (level=2)
- Statistics
- ----------------------------------------------------------
- 0 recursive calls
- 0 db block gets
- 15004 consistent gets
- 15000 physical reads
- 0 redo size
- 527 bytes sent via SQL*Net to client
- 523 bytes received via SQL*Net from client
- 2 SQL*Net roundtrips to/from client
- 0 sorts (memory)
- 0 sorts (disk)
- 1 rows processed
- SQL> alter session set events '10046 trace name context forever,level 8';
- Session altered.
- SQL> select count(*) from maclean_tan2;
- COUNT(*)
- ----------
- 15000
-
- SQL> oradebug setmypid;
- Statement processed.
- SQL> oradebug tracefile_name
- /s01/orabase/diag/rdbms/vprod/VPROD1/trace/VPROD1_ora_29876.trc
- PARSING IN CURSOR #140118795641360 len=33 dep=0 uid=0 oct=3 lid=0 tim=1340511245212199 hv=486583032 ad='76883110' sqlid='drryzcwfh1ars'
- select count(*) from maclean_tan2
- END OF STMT
- PARSE #140118795641360:c=6000,e=35195,p=0,cr=77,cu=0,mis=1,r=0,dep=0,og=1,plh=1229461046,tim=1340511245212192
- EXEC #140118795641360:c=0,e=54,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=1229461046,tim=1340511245212328
- WAIT #140118795641360: nam='SQL*Net message to client' ela= 13 driver id=1650815232 #bytes=1 p3=0 obj#=79780 tim=1340511245212395
- WAIT #140118795641360: nam='asynch descriptor resize' ela= 11 outstanding #aio=0 current aio limit=235 new aio limit=265 obj#=79780 tim=1340511245214369
- WAIT #140118795641360: nam='direct path read' ela= 140 file number=1 first dba=200555 block cnt=1 obj#=79780 tim=1340511245276928
- WAIT #140118795641360: nam='direct path read' ela= 124 file number=1 first dba=200683 block cnt=1 obj#=79780 tim=1340511245294008
- WAIT #140118795641360: nam='direct path read' ela= 126 file number=1 first dba=201707 block cnt=1 obj#=79780 tim=1340511245425743
- WAIT #140118795641360: nam='direct path read' ela= 170 file number=1 first dba=201835 block cnt=1 obj#=79780 tim=1340511245454308
- WAIT #140118795641360: nam='direct path read' ela= 126 file number=1 first dba=201963 block cnt=1 obj#=79780 tim=1340511245472445
- WAIT #140118795641360: nam='direct path read' ela= 113 file number=1 first dba=202091 block cnt=1 obj#=79780 tim=1340511245488926
- WAIT #140118795641360: nam='direct path read' ela= 116 file number=1 first dba=202219 block cnt=1 obj#=79780 tim=1340511245505475
- WAIT #140118795641360: nam='direct path read' ela= 116 file number=1 first dba=202475 block cnt=1 obj#=79780 tim=1340511245539057
- WAIT #140118795641360: nam='direct path read' ela= 157 file number=1 first dba=202603 block cnt=1 obj#=79780 tim=1340511245556950
- WAIT #140118795641360: nam='direct path read' ela= 31 file number=1 first dba=202987 block cnt=1 obj#=79780 tim=1340511245608673
- WAIT #140118795641360: nam='direct path read' ela= 131 file number=1 first dba=203115 block cnt=1 obj#=79780 tim=1340511245624922
- WAIT #140118795641360: nam='direct path read' ela= 113 file number=1 first dba=203755 block cnt=1 obj#=79780 tim=1340511245706298
- WAIT #140118795641360: nam='direct path read' ela= 28 file number=1 first dba=203883 block cnt=1 obj#=79780 tim=1340511245722656
- WAIT #140118795641360: nam='direct path read' ela= 13 file number=1 first dba=204011 block cnt=1 obj#=79780 tim=1340511245738218
- WAIT #140118795641360: nam='direct path read' ela= 31 file number=1 first dba=204523 block cnt=1 obj#=79780 tim=1340511245801733
- direct path read 而非 db file scattered read
- 11g new feature 对于大表 的FULL SCAN 可以直接采用 direct path read 读入PGA 而不经过 buffer cache
- ALTER SESSION SET EVENTS '10949 TRACE NAME CONTEXT FOREVER';
- 10949 event 可以禁止 11g 的这种特性;
- [oracle@vrh1 ~]$ oerr ora 10949
- 10949, 00000, "Disable autotune direct path read for full table scan"
- // *Cause:
- // *Action: Disable autotune direct path read for serial full table scan.
- _small_table_threshold 设置为较大值 避免 optimizer 将这个表视为大表 buffer 被flush
- SQL>
- SQL> alter session set "_small_table_threshold"=999999;
- Session altered.
- SQL> ALTER SESSION SET EVENTS '10949 TRACE NAME CONTEXT FOREVER';
- Session altered.
- SQL> select count(*) from maclean_tan2;
- COUNT(*)
- ----------
- 15000
- SQL> set autotrace on;
- SQL> select count(*) from maclean_tan2;
- COUNT(*)
- ----------
- 15000
- Execution Plan
- ----------------------------------------------------------
- Plan hash value: 1229461046
- ---------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Cost (%CPU)| Time |
- ---------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | 1 | 4069 (1)| 00:00:49 |
- | 1 | SORT AGGREGATE | | 1 | | |
- | 2 | TABLE ACCESS FULL| MACLEAN_TAN2 | 15476 | 4069 (1)| 00:00:49 |
- ---------------------------------------------------------------------------
- Note
- -----
- - dynamic sampling used for this statement (level=2)
- Statistics
- ----------------------------------------------------------
- 0 recursive calls
- 0 db block gets
- 15011 consistent gets
- 0 physical reads
- 0 redo size
- 527 bytes sent via SQL*Net to client
- 523 bytes received via SQL*Net from client
- 2 SQL*Net roundtrips to/from client
- 0 sorts (memory)
- 0 sorts (disk)
- 1 rows processed
- SQL> select count(*) from maclean_tan2;
- COUNT(*)
- ----------
- 15000
- Execution Plan
- ----------------------------------------------------------
- Plan hash value: 1229461046
- ---------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Cost (%CPU)| Time |
- ---------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | 1 | 4069 (1)| 00:00:49 |
- | 1 | SORT AGGREGATE | | 1 | | |
- | 2 | TABLE ACCESS FULL| MACLEAN_TAN2 | 15476 | 4069 (1)| 00:00:49 |
- ---------------------------------------------------------------------------
- Note
- -----
- - dynamic sampling used for this statement (level=2)
- Statistics
- ----------------------------------------------------------
- 0 recursive calls
- 0 db block gets
- 15011 consistent gets
- 0 physical reads
- 0 redo size
- 527 bytes sent via SQL*Net to client
- 523 bytes received via SQL*Net from client
- 2 SQL*Net roundtrips to/from client
- 0 sorts (memory)
- 0 sorts (disk)
- 1 rows processed
- http://www.oracledatabase12g.com/archives/script-list-buffer-cache-details.html
- 参考以上网址的脚本
- set pages 999
- set lines 92
- column c0 heading "Owner" format a12
- column c1 heading "Object|Name" format a30
- column c2 heading "Object|Type" format a8
- column c3 heading "Number of|Blocks in|Buffer|Cache" format 99,999,999
- column c4 heading "Percentage|of object|blocks in|Buffer" format 999
- column c5 heading "Buffer|Pool" format a7
- column c6 heading "Block|Size" format 99,999
-
- select
- buffer_map.owner c0,
- object_name c1,
- case when object_type = 'TABLE PARTITION' then 'TAB PART'
- when object_type = 'INDEX PARTITION' then 'IDX PART'
- else object_type end c2,
- sum(num_blocks) c3,
- (sum(num_blocks)/greatest(sum(blocks), .001))*100 c4,
- buffer_pool c5,
- sum(bytes)/sum(blocks) c6
- from
- buffer_map,
- dba_segments s
- where
- s.segment_name = buffer_map.object_name
- and
- s.owner = buffer_map.owner
- and
- s.segment_type = buffer_map.object_type
- and
- nvl(s.partition_name,'-') = nvl(buffer_map.subobject_name,'-')
- group by
- buffer_map.owner,
- object_name,
- object_type,
- buffer_pool
- having
- sum(num_blocks) > 10
- order by
- sum(num_blocks) desc
- ;
- Number of Percentage
- Blocks in of object
- Object Object Buffer blocks in Buffer Block
- Owner Name Type Cache Buffer Pool Size
- ------------ ------------------------------ -------- ----------- ---------- ------- -------
- SYS MACLEAN_TAN2 TABLE 15,001 98 KEEP 8,192
- SYS C_TOID_VERSION# CLUSTER 1,765 57 DEFAULT 8,192
- SYS C_OBJ# CLUSTER 1,428 93 DEFAULT 8,192
- SYS OBJ$ TABLE 931 91 DEFAULT 8,192
- SYS I_OBJ2 INDEX 760 99 DEFAULT 8,192
- SYS C_FILE#_BLOCK# CLUSTER 198 77 DEFAULT 8,192
- SYS I_FILE#_BLOCK# INDEX 40 100 DEFAULT 8,192
- SYS I_OBJ1 INDEX 37 14 DEFAULT 8,192
- SYS INDPART$ TABLE 16 100 DEFAULT 8,192
- SYS I_HH_OBJ#_INTCOL# INDEX 15 12 DEFAULT 8,192
- SYS HIST_HEAD$ TABLE 15 4 DEFAULT 8,192
- SYS AQ$_SYS$SERVICE_METRICS_TAB_S TABLE 14 88 DEFAULT 8,192
- SYS C_TS# CLUSTER 13 81 DEFAULT 8,192
- SYS I_DEPENDENCY1 INDEX 13 2 DEFAULT 8,192
- SYS I_ACCESS1 INDEX 12 2 DEFAULT 8,192
- 15 rows selected.
- 可以看到 MACLEAN_TAN2 表在 keep buffer pool中的详细信息, 15,001 blocks= 117MB
-
-
复制代码 |
|