因此,我们有一个有点复杂的SQL查询。我们系统的性能在大约1.1秒内返回结果。在客户环境中,查询返回大约2.4-2.5秒。在两台服务器上运行统计信息,我们注意到一致性获取的巨大差异。我们比较了一些参数,看看是否有缓存差异,但我不完全确定要看什么。我们注意到他们的系统上的DB_FILE_MULTIBLOCK_READ_COUNT是8到128.基本上,看看下面的内容,你有什么方向可以让我们更仔细地匹配这些统计数据。
或者,一致的获取是如此不同并不重要?
**Our Statistics**
0 recursive calls
0 db block gets
28344 consistent gets
0 physical reads
188 redo size
1664150 bytes sent via SQL*Net to client
36494 bytes received via SQL*Net from client
3272 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
49053 rows processed
**Client Statistics**
0 recursive calls
1 db block gets
306456 consistent gets
288 physical reads
188 redo size
1879562 bytes sent via SQL*Net to client
36494 bytes received via SQL*Net from client
3272 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
49053 rows processed
我们的计划:
选择49053行。
Execution Plan
----------------------------------------------------------
Plan hash value: 60030630
--------------------------------------------------------------------------------
-------------------------------------------------
| Id | Operation | Name
| Rows | Bytes |TempSpc| Cost (%CPU)| Time |
--------------------------------------------------------------------------------
-------------------------------------------------
| 0 | SELECT STATEMENT |
| 454M| 160G| | 262K (7)| 00:52:27 |
|* 1 | HASH JOIN RIGHT OUTER |
| 454M| 160G| | 262K (7)| 00:52:27 |
| 2 | VIEW |
| 9 | 1935 | | 6 (17)| 00:00:01 |
| 3 | MERGE JOIN |
| 9 | 198 | | 6 (17)| 00:00:01 |
| 4 | TABLE ACCESS BY INDEX ROWID | TBLWORKFLOWSTAGES
| 9 | 144 | | 2 (0)| 00:00:01 |
| 5 | INDEX FULL SCAN | PK_TBLWORKFLOWSTAGES
| 9 | | | 1 (0)| 00:00:01 |
|* 6 | SORT JOIN |
| 9 | 54 | | 4 (25)| 00:00:01 |
| 7 | TABLE ACCESS FULL | TBLWORKFLOWSTAGETREE
| 9 | 54 | | 3 (0)| 00:00:01 |
|* 8 | HASH JOIN RIGHT OUTER |
| 454M| 69G| | 258K (6)| 00:51:48 |
| 9 | TABLE ACCESS FULL | TBLTASKDEFINITIONS
| 4 | 148 | | 3 (0)| 00:00:01 |
|* 10 | HASH JOIN |
| 454M| 53G| 22M| 255K (4)| 00:51:10 |
|* 11 | INDEX FAST FULL SCAN | IDX_IAM_AS_ID_IN_ID_ACCESS
| 983K| 11M| | 1842 (2)| 00:00:23 |
|* 12 | FILTER |
| | | | | |
|* 13 | HASH JOIN RIGHT OUTER |
| 39M| 4385M| | 9180 (71)| 00:01:51 |
| 14 | TABLE ACCESS FULL | TBLASSETSTATUSES
| 4 | 24 | | 3 (0)| 00:00:01 |
|* 15 | HASH JOIN |
| 79M| 8313M| | 8614 (69)| 00:01:44 |
|* 16 | HASH JOIN RIGHT SEMI |
| 8316 | 446K| | 2167 (2)| 00:00:27 |
| 17 | INDEX FULL SCAN | PK_TBLWORKFLOWSTAGETREEPARENTS
| 7 | 21 | | 1 (0)| 00:00:01 |
| 18 | VIEW |
| 49895 | 2533K| | 2165 (2)| 00:00:26 |
| 19 | UNION-ALL |
| | | | | |
| 20 | NESTED LOOPS ANTI |
| 1 | 144 | | 1 (0)| 00:00:01 |
| 21 | NESTED LOOPS |
| 1 | 106 | | 1 (0)| 00:00:01 |
| 22 | INDEX FULL SCAN | PK_TBLWORKMGMTGP
| 1 | 13 | | 0 (0)| 00:00:01 |
|* 23 | TABLE ACCESS BY INDEX ROWID| TBLASSETTASKS
| 1 | 93 | | 1 (0)| 00:00:01 |
|* 24 | INDEX UNIQUE SCAN | PK_TBLASSETTASKS
| 1 | | | 1 (0)| 00:00:01 |
|* 25 | INDEX FULL SCAN | PK_TBLASSETTASKCOPIES
| 1 | 38 | | 0 (0)| 00:00:01 |
| 26 | NESTED LOOPS ANTI |
| 49894 | 6626K| | 2164 (2)| 00:00:26 |
| 27 | NESTED LOOPS |
| 49894 | 4775K| | 2163 (2)| 00:00:26 |
|* 28 | TABLE ACCESS FULL | TBLASSETTASKS
| 122K| 10M| | 2147 (1)| 00:00:26 |
|* 29 | INDEX UNIQUE SCAN | PK_TBLWORKMGMTINST
| 1 | 5 | | 0 (0)| 00:00:01 |
|* 30 | INDEX FULL SCAN | PK_TBLASSETTASKCOPIES
| 1 | 38 | | 0 (0)| 00:00:01 |
|* 31 | TABLE ACCESS FULL | TBLASSETS
| 827M| 41G| | 622 (1)| 00:00:08 |
--------------------------------------------------------------------------------
-------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("QUERYTABLE"."AST_CURRENT_WFST_ID"="DISPLAYTABLE1"."WFST_ID"(+))
6 - access("WFST"."WFS_ID"="WFS"."WFS_ID")
filter("WFST"."WFS_ID"="WFS"."WFS_ID")
8 - access("DISPLAYTABLE2"."TD_ID"(+)="QUERYTABLE"."TD_ID")
10 - access("TBLASSETS"."AS_ID"="TBLINSPECTORASSETMAP"."AS_ID")
11 - filter("TBLINSPECTORASSETMAP"."IN_ID"=1 AND ("TBLINSPECTORASSETMAP"."IAM_
ASSET_ACCESS_LEVEL"=0 OR
"TBLINSPECTORASSETMAP"."IAM_ASSET_ACCESS_LEVEL"=1))
12 - filter("TBLASSETSTATUSES"."ASSET_STATUS_HIDE_REPORTS" IS NULL OR "TBLASSE
TSTATUSES"."ASSET_STATUS_HIDE_REPORTS"=0)
13 - access("TBLASSETSTATUSES"."ASSET_STATUS_ID"(+)="TBLASSETS"."ASSET_STATUS_
ID")
15 - access("QUERYTABLE"."AS_ID"="TBLASSETS"."AS_ID")
16 - access("QUERYTABLE"."AST_CURRENT_WFST_ID"="PARENT_WFST_ID")
23 - filter("TBLASSETTASKS"."AST_TYPE"=3 AND "AST_DELETED"=0)
24 - access("TBLASSETTASKS"."AST_ID"="TBLWORKMGMTGP"."AST_ID")
25 - access("TBLASSETTASKS"."AST_GUID"="COPY_AST_GUID")
filter("TBLASSETTASKS"."AST_GUID"="COPY_AST_GUID")
28 - filter("TBLASSETTASKS"."AST_TYPE"=4 AND "AST_DELETED"=0)
29 - access("TBLASSETTASKS"."AST_ID"="TBLWORKMGMTINST"."AST_ID")
30 - access("TBLASSETTASKS"."AST_GUID"="COPY_AST_GUID")
filter("TBLASSETTASKS"."AST_GUID"="COPY_AST_GUID")
31 - filter("AS_DELETED"=0 AND ("TBLASSETS"."AS_ASSET_DEF"=0 OR "TBLASSETS"."A
S_ASSET_DEF"=1))
Note
-----
- SQL profile "SYS_SQLPROF_014054654a1d0000" used for this statement
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
28343 consistent gets
0 physical reads
0 redo size
1664150 bytes sent via SQL*Net to client
36494 bytes received via SQL*Net from client
3272 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
49053 rows processed
他们的计划:
Execution Plan
----------------------------------------------------------
Plan hash value: 854387336
--------------------------------------------------------------------------------
------------------------------------------
| Id | Operation | Name
| Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------
------------------------------------------
| 0 | SELECT STATEMENT |
| 1 | 353 | 1321 (1)| 00:00:16 |
| 1 | NESTED LOOPS OUTER |
| 1 | 353 | 1321 (1)| 00:00:16 |
| 2 | NESTED LOOPS OUTER |
| 1 | 149 | 1319 (1)| 00:00:16 |
|* 3 | FILTER |
| | | | |
| 4 | NESTED LOOPS OUTER |
| 1 | 114 | 1318 (1)| 00:00:16 |
| 5 | NESTED LOOPS |
| 1 | 110 | 1317 (1)| 00:00:16 |
| 6 | NESTED LOOPS |
| 1 | 103 | 1317 (1)| 00:00:16 |
| 7 | NESTED LOOPS SEMI |
| 1 | 54 | 1316 (1)| 00:00:16 |
| 8 | VIEW |
| 49426 | 2509K| 1315 (1)| 00:00:16 |
| 9 | NESTED LOOPS ANTI |
| 49426 | 6178K| 1315 (1)| 00:00:16 |
| 10 | VIEW | VW_JF_SET$10554C5A
| 49427 | 4344K| 1314 (1)| 00:00:16 |
| 11 | UNION-ALL |
| | | | |
| 12 | NESTED LOOPS |
| | | | |
| 13 | NESTED LOOPS |
| 1 | 106 | 1 (0)| 00:00:01 |
| 14 | INDEX FULL SCAN | PK_TBLWORKMGMTGP
| 1 | 13 | 0 (0)| 00:00:01 |
|* 15 | INDEX UNIQUE SCAN | PK_TBLASSETTASKS
| 1 | | 0 (0)| 00:00:01 |
|* 16 | TABLE ACCESS BY INDEX ROWID| TBLASSETTASKS
| 1 | 93 | 1 (0)| 00:00:01 |
| 17 | NESTED LOOPS |
| 49426 | 4730K| 1313 (1)| 00:00:16 |
|* 18 | TABLE ACCESS BY INDEX ROWID| TBLASSETTASKS
| 49426 | 4488K| 1310 (1)| 00:00:16 |
|* 19 | INDEX RANGE SCAN | TBLINSPECTIONREPORT_IR_TYPE
| 49456 | | 106 (1)| 00:00:02 |
|* 20 | INDEX UNIQUE SCAN | PK_TBLWORKMGMTINST
| 1 | 5 | 0 (0)| 00:00:01 |
|* 21 | INDEX FULL SCAN | PK_TBLASSETTASKCOPIES
| 1 | 38 | 0 (0)| 00:00:01 |
|* 22 | INDEX RANGE SCAN | PK_TBLWORKFLOWSTAGETREEPARENTS
| 1 | 2 | 0 (0)| 00:00:01 |
|* 23 | TABLE ACCESS BY INDEX ROWID | TBLASSETS
| 1 | 49 | 1 (0)| 00:00:01 |
|* 24 | INDEX RANGE SCAN | IDX_ASSET_STATUS_ASID_DELETED
| 1 | | 0 (0)| 00:00:01 |
| 25 | INLIST ITERATOR |
| | | | |
|* 26 | INDEX RANGE SCAN | IDX_IAM_AS_ID_IN_ID_ACCESS
| 2 | 14 | 0 (0)| 00:00:01 |
| 27 | TABLE ACCESS BY INDEX ROWID | TBLASSETSTATUSES
| 1 | 4 | 1 (0)| 00:00:01 |
|* 28 | INDEX UNIQUE SCAN | PK_TBLASSETSTATUS
| 1 | | 0 (0)| 00:00:01 |
| 29 | TABLE ACCESS BY INDEX ROWID | TBLTASKDEFINITIONS
| 1 | 35 | 1 (0)| 00:00:01 |
|* 30 | INDEX UNIQUE SCAN | PK_TBLTASKDEFINITIONS
| 1 | | 0 (0)| 00:00:01 |
| 31 | VIEW PUSHED PREDICATE |
| 1 | 204 | 2 (0)| 00:00:01 |
| 32 | NESTED LOOPS |
| 1 | 18 | 2 (0)| 00:00:01 |
| 33 | TABLE ACCESS BY INDEX ROWID | TBLWORKFLOWSTAGETREE
| 1 | 4 | 1 (0)| 00:00:01 |
|* 34 | INDEX UNIQUE SCAN | PK_TBLWORKFLOWSTAGEFLOW
| 1 | | 0 (0)| 00:00:01 |
| 35 | TABLE ACCESS BY INDEX ROWID | TBLWORKFLOWSTAGES
| 9 | 126 | 1 (0)| 00:00:01 |
|* 36 | INDEX UNIQUE SCAN | PK_TBLWORKFLOWSTAGES
| 1 | | 0 (0)| 00:00:01 |
--------------------------------------------------------------------------------
------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - filter("TBLASSETSTATUSES"."ASSET_STATUS_HIDE_REPORTS" IS NULL OR
"TBLASSETSTATUSES"."ASSET_STATUS_HIDE_REPORTS"=0)
15 - access("TBLASSETTASKS"."AST_ID"="TBLWORKMGMTGP"."AST_ID")
16 - filter("TBLASSETTASKS"."AST_TYPE"=3 AND "AST_DELETED"=0)
18 - filter("AST_DELETED"=0)
19 - access("TBLASSETTASKS"."AST_TYPE"=4)
20 - access("TBLASSETTASKS"."AST_ID"="TBLWORKMGMTINST"."AST_ID")
21 - access("ITEM_1"="COPY_AST_GUID")
filter("ITEM_1"="COPY_AST_GUID")
22 - access("AST_CURRENT_WFST_ID"="PARENT_WFST_ID")
23 - filter("TBLASSETS"."AS_ASSET_DEF"=0 OR "TBLASSETS"."AS_ASSET_DEF"=1)
24 - access("AS_ID"="TBLASSETS"."AS_ID" AND "AS_DELETED"=0)
26 - access("TBLASSETS"."AS_ID"="TBLINSPECTORASSETMAP"."AS_ID" AND "TBLINSPECT
ORASSETMAP"."IN_ID"=1 AND
("TBLINSPECTORASSETMAP"."IAM_ASSET_ACCESS_LEVEL"=0 OR "TBLINSPECTO
RASSETMAP"."IAM_ASSET_ACCESS_LEVEL"=1))
28 - access("TBLASSETSTATUSES"."ASSET_STATUS_ID"(+)="TBLASSETS"."ASSET_STATUS_
ID")
30 - access("DISPLAYTABLE2"."TD_ID"(+)="TD_ID")
34 - access("WFST"."WFST_ID"="AST_CURRENT_WFST_ID")
36 - access("WFST"."WFS_ID"="WFS"."WFS_ID")
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
337565 consistent gets
0 physical reads
0 redo size
1728165 bytes sent via SQL*Net to client
23140 bytes received via SQL*Net from client
3272 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
49051 rows processed
答案 0 :(得分:1)
DB_FILE_MULTIBLOCK_READ_COUNT的差异使得全表扫描在您的系统上可能比在他们的系统上更有效。在更新的版本中,您应该避免明确地设置它,因为它将在该环境中默认为最大可能。听起来有点不合理。
数据的导入不会与数据布局完全匹配 - 您仍然可以在数据存储方面存在显着差异,并且确切地保证数据和索引的相同布局的唯一方法是通过表空间运输。
PGA的低设置可以想象会阻止大型散列连接,因为多通道分类的成本增加会增加估计的成本。
所以无论如何,它看起来像你的解释计划时间估计是疯狂的。您是否考虑过收集系统统计信息,以便优化器能够公平估计单块和多块读取以及CPU操作所需的时间?
答案 1 :(得分:0)
最重要的区别是您的系统使用SQL配置文件(正如Justin Cave猜测的那样):
Note
-----
- SQL profile "SYS_SQLPROF_014054654a1d0000" used for this statement
查看the manual以获取有关SQL配置文件的信息,例如如何修改它们并在服务器之间移动它们。
此外,this article by Kerry Osborne可以帮助您准确了解个人资料的用途。
如果您想快速强制计划相同,请使用选项dbms_xplan
运行format => 'outline'
。这将创建一大堆提示,完全控制计划。您可能不想永久使用这些提示。但是,如果您可以在即席查询中快速复制计划,则至少可以排除其他环境差异。