Oracle数据库数据恢复、性能优化

找回密码
注册
搜索
热搜: 活动 交友 discuz
发新帖
1#
发表于 2014-4-9 20:54:06


SQL> select count(*) from macdt;

  COUNT(*)
----------
    617992

       
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


alter session set events '10046 trace name context forever,level 12';

alter system flush buffer_cache;

select /*+ DYNAMIC_SAMPLING(t 1) */ count(*) from macdt t;


alter system flush buffer_cache;

select /*+ DYNAMIC_SAMPLING(t 2) */ count(*) from macdt t;


alter system flush buffer_cache;

select /*+ DYNAMIC_SAMPLING(t 3) */ count(*) from macdt t;



alter system flush buffer_cache;

select /*+ DYNAMIC_SAMPLING(t 4) */ count(*) from macdt t;


alter system flush buffer_cache;

select /*+ DYNAMIC_SAMPLING(t 10) */ count(*) from macdt t;
















DYNAMIC_SAMPLING(t 1)  时的动态采用语句

SELECT /* OPT_DYN_SAMP */ /*+ ALL_ROWS IGNORE_WHERE_CLAUSE NO_PARALLEL(SAMPLESUB) opt_param('parallel_execution_enabled', 'false') NO_PARALLEL_INDEX(SAMPLESUB) NO_SQL_TUNE */ NVL(SUM(C1),0)
, NVL(SUM(C2),0) FROM (SELECT /*+ NO_PARALLEL("T") FULL("T") NO_PARALLEL_INDEX("T") */ 1 AS C1, 1 AS C2 FROM "SYS"."MACDT" SAMPLE BLOCK (0.340547 , 1) SEED (1) "T") SAMPLESUB


DYNAMIC_SAMPLING(t 2)  时的动态采用语句


SELECT /* OPT_DYN_SAMP */ /*+ ALL_ROWS IGNORE_WHERE_CLAUSE NO_PARALLEL(SAMPLESUB) opt_param('parallel_execution_enabled', 'false') NO_PARALLEL_INDEX(SAMPLESUB) NO_SQL_TUNE */ NVL(SUM(C1),0)
, NVL(SUM(C2),0) FROM (SELECT /*+ NO_PARALLEL("T") FULL("T") NO_PARALLEL_INDEX("T") */ 1 AS C1, 1 AS C2 FROM "SYS"."MACDT" SAMPLE BLOCK (0.692080 , 1) SEED (1) "T") SAMPLESUB

DYNAMIC_SAMPLING(t 3)  时的动态采用语句


SELECT /* OPT_DYN_SAMP */ /*+ ALL_ROWS IGNORE_WHERE_CLAUSE NO_PARALLEL(SAMPLESUB) opt_param('parallel_execution_enabled', 'false') NO_PARALLEL_INDEX(SAMPLESUB) NO_SQL_TUNE */ NVL(SUM(C1),0)
, NVL(SUM(C2),0) FROM (SELECT /*+ NO_PARALLEL("T") FULL("T") NO_PARALLEL_INDEX("T") */ 1 AS C1, 1 AS C2 FROM "SYS"."MACDT" SAMPLE BLOCK (1.395144 , 1) SEED (1) "T") SAMPLESUB


DYNAMIC_SAMPLING(t 4)  时的动态采用语句


SELECT /* OPT_DYN_SAMP */ /*+ ALL_ROWS IGNORE_WHERE_CLAUSE NO_PARALLEL(SAMPLESUB) opt_param('parallel_execution_enabled', 'false') NO_PARALLEL_INDEX(SAMPLESUB) NO_SQL_TUNE */ NVL(SUM(C1),0)
, NVL(SUM(C2),0) FROM (SELECT /*+ NO_PARALLEL("T") FULL("T") NO_PARALLEL_INDEX("T") */ 1 AS C1, 1 AS C2 FROM "SYS"."MACDT" SAMPLE BLOCK (2.801274 , 1) SEED (1) "T") SAMPLESUB


DYNAMIC_SAMPLING(t 10)  时的动态采用语句

SELECT /* OPT_DYN_SAMP */ /*+ ALL_ROWS IGNORE_WHERE_CLAUSE NO_PARALLEL(SAMPLESUB) opt_param('parallel_execution_enabled', 'false') NO_PARALLEL_INDEX(SAMPLESUB) NO_SQL_TUNE */ NVL(SUM(C1),0)
, NVL(SUM(C2),0) FROM (SELECT /*+ NO_PARALLEL("T") FULL("T") NO_PARALLEL_INDEX("T") */ 1 AS C1, 1 AS C2 FROM "SYS"."MACDT" "T") SAMPLESUB


回复 显示全部楼层 道具 举报

2#
发表于 2014-4-9 21:00:56
1 sample block 0.340547
2 sample block  0.692080
3 sample block 1.395144
4 sample block  2.801274
10 没有该信息

LevelWhen Dynamic Sampling will be usedSample size (blocks)
0Switches off dynamic samplingN/A
1At least one non-partitioned table in the statement has no statistics32
2 (default)One or more tables in the statement have no statistics64
3Any statement that meets level 2 criteria and any statement that has one or more expressions used in the where clause predicates e.g. Where substr(CUSTLASTNAME,1,3) or Where a + b =564
4Any statement that meets level 3 criteria and any statement that has complex predicates. An OR or AND operator between multiple predicates on the same table64
5Any statement that meets level 4 criteria128
6Any statement that meets level 4 criteria256
7Any statement that meets level 4 criteria512
8Any statement that meets level 4 criteria1024
9Any statement that meets level 4 criteria4086
10All statementsAll Blocks

回复 显示全部楼层 道具 举报

3#
发表于 2014-4-9 21:02:52
如上 采用不同的 DYNAMIC_SAMPLING粒度 实际是有区别的,但是set autotrace 在欺骗你, 研究ORACLE不要过于依靠set autotrace

回复 显示全部楼层 道具 举报

4#
发表于 2014-4-10 22:04:53
typ281 发表于 2014-4-10 02:37
不好意思,提问的时候忘记粘贴显示执行计划的代码了,我是使用 select * from table(dbms_xplan.display_cu ...

请仔细看3、4楼,我想我已经说明该问题了

回复 显示全部楼层 道具 举报

您需要登录后才可以回帖 登录 | 注册

QQ|手机版|Archiver|Oracle数据库数据恢复、性能优化

GMT+8, 2024-6-2 09:23 , Processed in 0.084510 second(s), 20 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部
TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569