點擊上方“IT那活兒”公眾號,關注后了解更多內容,不管IT什么活兒,干就完了?。?!
SELECT B.ID,
B.NAME,
B.TASK_ID,
B.DICTION,
B.GROUP_ID,
NVL(B.ATTEST_FLAG, N),
NVL(B.DOUWIN_FLAG, N),
B.DESC,
NVL(B.SIGN_FLAG, N),
B.MAX_EXECUTE_NUM
FROM (SELECT DISTINCT (ID)
FROM TEST_TAB
WHERE STATUS = 04
AND CHN_TYPE = :B1) A,
TABLE(CAST(:B2 AS TYPE_INFO_TABLE)) B
WHERE A.ID = B.ID
Plan hash value: 918180822
-----------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 839 (100)| |
|* 1 | HASH JOIN | | 5784 | 75192 | 839 (5)| 00:00:05 |
| 2 | COLLECTION ITERATOR PICKLER FETCH| | | | | |
| 3 | VIEW | | 12361 | 132K| 818 (5)| 00:00:05 |
| 4 | HASH UNIQUE | | 12361 | 301K| 818 (5)| 00:00:05 |
|* 5 | TABLE ACCESS FULL | TEST_TAB | 21104 | 515K| 814 (4)| 00:00:05 |
-----------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("A"."ID"=SYS_OP_ATG(VALUE(KOKBF$),1,2,2))
5 - filter(("CHN_TYPE"=:B1 AND "STATUS"=04))
SQL> explain plan for
2 SELECT *
3 FROM TABLE(CAST(:B2 AS TYPE_INFO_TABLE));
Explained.
Elapsed: 00:00:00.01
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------
Plan hash value: 1692170009
------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 8168 | 16336 | 14 (0)| 00:00:01 |
| 1 | COLLECTION ITERATOR PICKLER FETCH| | | | | |
------------------------------------------------------------------------------------------
SQL> explain plan for
2 select/*+cardinality(b 100)*/ * from
3 TABLE(CAST(:B2 AS TYPE_INFO_TABLE)) B;
Explained.
Elapsed: 00:00:00.06
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------
Plan hash value: 1692170009
------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 100 | 200 | 20 (0)| 00:00:01 |
| 1 | COLLECTION ITERATOR PICKLER FETCH| | | | | |
------------------------------------------------------------------------------------------
8 rows selected.
SQL> explain plan for
2 select/*+opt_estimate(table,b,rows=100)*/ * from
3 TABLE(CAST(:B2 AS TYPE_INFO_TABLE)) B;
Explained.
Elapsed: 00:00:00.01
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------
Plan hash value: 1692170009
------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 100 | 200 | 20 (0)| 00:00:01 |
| 1 | COLLECTION ITERATOR PICKLER FETCH| | | | | |
------------------------------------------------------------------------------------------
8 rows selected.
Elapsed: 00:00:00.04
2. 通過分析語句只訪問TABLE函數返回的行,為了做JOIN,使用了DISTINCT,是沒有必要的,而且會影響執行計劃,這里通過EXISTS子查詢改寫。
SELECT/*+cardinality(b 100)*/ B.ID, B.NAME, B.TASK_ID, B.DICTION, B.GROUP_ID,NVL(B.ATTEST_FLAG,N), NVL(B.DOUWIN_FLAG,N), B.DESC, NVL(B.SIGN_FLAG,N),B.MAX_EXECUTE_NUM
FROM TABLE(CAST(:B2 AS TYPE_INFO_TABLE)) B
WHERE EXISTS(SELECT 1 FROM TEST_TAB A
WHERE A.STATUS = 04
AND A.CHN_TYPE = :B1
AND A.ID = B.ID
);
Plan hash value: 3464704515
------------------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
------------------------------------------------------------------------------------------------------------------------------------------
|* 1 | HASH JOIN | | 1 | 1787 | 75 |00:00:00.27 | 4283 | 1959K| 1363K| 2182K (0)|
| 2 | VIEW | | 1 | 3807 | 27100 |00:00:00.25 | 4283 | | | |
| 3 | HASH UNIQUE | | 1 | 3807 | 27100 |00:00:00.25 | 4283 | 1983K| 1380K| 1725K (0)|
|* 4 | TABLE ACCESS FULL | TEST_TAB | 1 | 4281 | 208K|00:00:00.21 | 4283 | | | |
| 5 | COLLECTION ITERATOR PICKLER FETCH| | 1 | | 75 |00:00:00.01 | 0 | | | |
------------------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("A"."ID"=SYS_OP_ATG(VALUE(KOKBF$),1,2,2))
4 - filter(("CHN_TYPE"=:B1 AND "STATUS"=04))
Plan hash value: 884413475
------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
------------------------------------------------------------------------------------------------------------------
| 1 | NESTED LOOPS SEMI | | 1 | 1 | 75 |00:00:00.01 | 227 |
| 2 | COLLECTION ITERATOR PICKLER FETCH| | 1 | | 75 |00:00:00.01 | 0 |
|* 3 | TABLE ACCESS BY INDEX ROWID | TEST_TAB | 75 | 1 | 75 |00:00:00.01 | 227 |
|* 4 | INDEX RANGE SCAN | PK_TEST_TAB | 75 | 2 | 75 |00:00:00.01 | 152 |
------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - filter("A"."STATUS"=04)
4 - access("A"."ID"=SYS_OP_ATG(VALUE(KOKBF$),1,2,2) AND "A"."CHN_TYPE"=:B2)
filter("A"."CHN_TYPE"=:B2)
文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。
轉載請注明本文地址:http://m.specialneedsforspecialkids.com/yun/129208.html
摘要:引導優化器按照哈希掃描的方式從表中讀取數據。告訴優化器強制選擇位圖索引。這個提示會使優化器合并表上的多個位圖索引,而不是選擇其中最好的索引這是提示的用途。還可以使用指定單個索引對于指定位圖索引,該提示優先于提示。 一、提示(Hint)概述 1、為什么引入Hint? Hint是Oracle數據庫中很有特色的一個功能,是很多DBA優化中經常采用的一個手段。那為什么Oracle會考慮引入優化...
閱讀 1353·2023-01-11 13:20
閱讀 1700·2023-01-11 13:20
閱讀 1212·2023-01-11 13:20
閱讀 1904·2023-01-11 13:20
閱讀 4162·2023-01-11 13:20
閱讀 2751·2023-01-11 13:20
閱讀 1397·2023-01-11 13:20
閱讀 3666·2023-01-11 13:20