- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
7#
发表于 2014-2-28 16:21:48
我不清楚你的测试是否刻意忽略 自动采样的影响,还是你没有意识到这个问题,实验必须足够精确。
这里为了体现自动采样的影响 采取了大表+optimizer_dynamic_sampling=10
Release 11.2.0.3.0
alter session set optimizer_dynamic_sampling=10;
drop table mac1;
create table mac1 tablespace users as select * from dba_objects ;
alter table mac1 nologging;
insert /*+ append */ into mac1 select * from mac1;
commit;
insert /*+ append */ into mac1 select * from mac1;
commit;
insert /*+ append */ into mac1 select * from mac1;
commit;
insert /*+ append */ into mac1 select * from mac1;
commit;
set arraysize 5000;
alter system flush shared_pool;
alter system flush buffer_cache;
alter session set events '10046 trace name context forever,level 12';
oradebug setmypid
oradebug tracefile_name
set autotrace traceonly;
select /* FINDME1 */ * from mac1;
Execution Plan
----------------------------------------------------------
Plan hash value: 2139598695
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1137K| 224M| 4461 (1)| 00:00:54 |
| 1 | TABLE ACCESS FULL| MAC1 | 1137K| 224M| 4461 (1)| 00:00:54 |
--------------------------------------------------------------------------
Note
-----
- dynamic sampling used for this statement (level=10)
Statistics
----------------------------------------------------------
71 recursive calls
2 db block gets
32678 consistent gets
16198 physical reads
168 redo size
116305305 bytes sent via SQL*Net to client
3021 bytes received via SQL*Net from client
229 SQL*Net roundtrips to/from client
2 sorts (memory)
0 sorts (disk)
1137216 rows processed
select disk_reads ,sql_id,sql_text from v$SQL where sql_text like '%FINDME%';
16198 bxx69d960vs2n
select /* FINDME1 */ * from mac1
/s01/diag/rdbms/asmdb1/ASMDB1/trace/ASMDB1_ora_1760.trc
select /* FINDME1 */ *
from
mac1
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 4 6 2 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 229 0.83 1.53 0 16424 0 1137216
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 231 0.83 1.53 4 16430 2 1137216
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS
Number of plan statistics captured: 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
1137216 1137216 1137216 TABLE ACCESS FULL MAC1 (cr=16424 pr=0 pw=0 time=253938 us cost=4460 size=235403712 card=1137216)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 229 0.00 0.00
SQL*Net message from client 229 0.01 3.01
SQL*Net more data to client 5412 0.00 0.73
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("MAC1") FULL("MAC1") NO_PARALLEL_INDEX("MAC1") */ 1
AS C1, 1 AS C2 FROM "SYS"."MAC1" "MAC1") SAMPLESUB
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 2 0.50 0.51 16188 32399 0 2
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 6 0.50 0.51 16188 32399 0 2
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS (recursive depth: 1)
Number of plan statistics captured: 2
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
1 1 1 SORT AGGREGATE (cr=16200 pr=8094 pw=0 time=256684 us)
1137216 1137216 1137216 TABLE ACCESS FULL MAC1 (cr=16200 pr=8094 pw=0 time=276240 us cost=4446 size=0 card=1335877)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file scattered read 143 0.00 0.08
从上面可以看到
autotrace 和 disk_reads 其实都里包含了 自动统计信息采样的物理读,其实还包括其他一些递归调用的物理读。
10046里体现的是该查询当时真正的统计值
|
|