因此,我們有一些複雜的SQL查詢。我們系統的性能在大約1.1秒內返回結果。在客戶環境中,查詢返回大約2.4-2.5秒。在兩臺服務器上運行統計數據,我們注意到一致性get的巨大差異。我們比較了一些參數,看看是否存在緩存差異,但我不完全確定要看什麼。我們確實注意到他們的系統上的DB_FILE_MULTIBLOCK_READ_COUNT是8,而我們的128.基本上,看下面的內容,有沒有什麼方向可以讓我們去讓這些統計數據更緊密地匹配。Oracle Consistent在兩臺服務器和性能之間有所不同
或者,一致性得到如此不同並不重要?
**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
第一件事是第一件事。這兩個系統上的查詢計劃是否相同?這兩個系統是否有完全相同的數據(即,您是從系統導出到您的環境中,還是在客戶使用實時數據運行時使用一些測試數據運行)?數據集有多不同?例如,如果您擁有100萬行測試數據,但客戶擁有2000萬行實時數據,則即使兩個查詢最終返回相同數量的行,比較統計數據也不會有意義。 –
應該提到這一點。數據完全一樣。我們幾天前進行了他們的數據導入。查詢計劃只有不同,因爲在客戶數據庫上進行了連接優化,而我們沒有使用該優化。除了連接優化之外,查詢計劃不會有所不同。相同的索引等。 – hammer
在這種情況下,「連接優化」是什麼意思?如果查詢計劃不同且客戶的網站性能下降,您確定客戶網站上的查詢計劃比您本地查詢計劃更有效嗎?如果你迫使兩個計劃相同,會發生什麼? –