關於查詢塊query block
explain plan for
select * from wxh_tbd where not exists (select /*+ unnest */1 from wxh_tbd1 where wxh_tbd1.object_id=wxh_tbd.object_id);
select * from wxh_tbd where not exists (select /*+ unnest */1 from wxh_tbd1 where wxh_tbd1.object_id=wxh_tbd.object_id);
Explained.
select * from table(dbms_xplan.display(null,null,'outline'));
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 325289001
---------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 325289001
---------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 19942 | 1908K| 76 (3)| 00:00:01 |
|* 1 | HASH JOIN RIGHT ANTI | | 19942 | 1908K| 76 (3)| 00:00:01 |
| 2 | INDEX FAST FULL SCAN| T_22 | 20411 | 99K| 12 (0)| 00:00:01 |
| 3 | TABLE ACCESS FULL | WXH_TBD | 20254 | 1839K| 63 (2)| 00:00:01 |
---------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 19942 | 1908K| 76 (3)| 00:00:01 |
|* 1 | HASH JOIN RIGHT ANTI | | 19942 | 1908K| 76 (3)| 00:00:01 |
| 2 | INDEX FAST FULL SCAN| T_22 | 20411 | 99K| 12 (0)| 00:00:01 |
| 3 | TABLE ACCESS FULL | WXH_TBD | 20254 | 1839K| 63 (2)| 00:00:01 |
---------------------------------------------------------------------------------
Outline Data
-------------
-------------
/*+
BEGIN_OUTLINE_DATA
SWAP_JOIN_INPUTS(@"SEL$5DA710D3" ")
USE_HASH(@"SEL$5DA710D3" ")
LEADING(@"SEL$5DA710D3" " ")
INDEX_FFS(@"SEL$5DA710D3" " ("WXH_TBD1"."OBJECT_ID"))
FULL(@"SEL$5DA710D3" ")
OUTLINE(@"SEL$2")
OUTLINE(@"SEL$1")
UNNEST(@"SEL$2")
OUTLINE_LEAF(@"SEL$5DA710D3")
ALL_ROWS
OPT_PARAM('_optim_peek_user_binds' 'false')
OPT_PARAM('_complex_view_merging' 'false')
DB_VERSION('11.1.0.7')
OPTIMIZER_FEATURES_ENABLE('11.1.0.7')
IGNORE_OPTIM_EMBEDDED_HINTS
END_OUTLINE_DATA
*/
BEGIN_OUTLINE_DATA
SWAP_JOIN_INPUTS(@"SEL$5DA710D3" ")
USE_HASH(@"SEL$5DA710D3" ")
LEADING(@"SEL$5DA710D3" " ")
INDEX_FFS(@"SEL$5DA710D3" " ("WXH_TBD1"."OBJECT_ID"))
FULL(@"SEL$5DA710D3" ")
OUTLINE(@"SEL$2")
OUTLINE(@"SEL$1")
UNNEST(@"SEL$2")
OUTLINE_LEAF(@"SEL$5DA710D3")
ALL_ROWS
OPT_PARAM('_optim_peek_user_binds' 'false')
OPT_PARAM('_complex_view_merging' 'false')
DB_VERSION('11.1.0.7')
OPTIMIZER_FEATURES_ENABLE('11.1.0.7')
IGNORE_OPTIM_EMBEDDED_HINTS
END_OUTLINE_DATA
*/
由於ORACLE自動對查詢做了解巢狀,展開了子查詢,因此生成了一個新的查詢塊SEL$5DA710D3。
看看強制不讓展開子查詢,查詢塊的命名是怎麼樣的。
explain plan for
select * from wxh_tbd where not exists (select /*+ no_unnest */1 from wxh_tbd1 where wxh_tbd1.object_id=wxh_tbd.object_id);
select * from wxh_tbd where not exists (select /*+ no_unnest */1 from wxh_tbd1 where wxh_tbd1.object_id=wxh_tbd.object_id);
Explained.
select * from table(dbms_xplan.display(null,null,'outline'));
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 3960225502
---------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 3960225502
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 20253 | 1839K| 10194 (1)| 00:02:03 |
|* 1 | FILTER | | | | | |
| 2 | TABLE ACCESS FULL| WXH_TBD | 20254 | 1839K| 63 (2)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | T_22 | 1 | 5 | 1 (0)| 00:00:01 |
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 20253 | 1839K| 10194 (1)| 00:02:03 |
|* 1 | FILTER | | | | | |
| 2 | TABLE ACCESS FULL| WXH_TBD | 20254 | 1839K| 63 (2)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | T_22 | 1 | 5 | 1 (0)| 00:00:01 |
------------------------------------------------------------------------------
Outline Data
-------------
-------------
/*+
BEGIN_OUTLINE_DATA
INDEX(@"SEL$2" " ("WXH_TBD1"."OBJECT_ID"))
FULL(@"SEL$1" ")
OUTLINE_LEAF(@"SEL$1")
OUTLINE_LEAF(@"SEL$2")
ALL_ROWS
OPT_PARAM('_optim_peek_user_binds' 'false')
OPT_PARAM('_complex_view_merging' 'false')
DB_VERSION('11.1.0.7')
OPTIMIZER_FEATURES_ENABLE('11.1.0.7')
IGNORE_OPTIM_EMBEDDED_HINTS
END_OUTLINE_DATA
*/
BEGIN_OUTLINE_DATA
INDEX(@"SEL$2" " ("WXH_TBD1"."OBJECT_ID"))
FULL(@"SEL$1" ")
OUTLINE_LEAF(@"SEL$1")
OUTLINE_LEAF(@"SEL$2")
ALL_ROWS
OPT_PARAM('_optim_peek_user_binds' 'false')
OPT_PARAM('_complex_view_merging' 'false')
DB_VERSION('11.1.0.7')
OPTIMIZER_FEATURES_ENABLE('11.1.0.7')
IGNORE_OPTIM_EMBEDDED_HINTS
END_OUTLINE_DATA
*/
從上面看到查詢塊的命名就是SEL$1,SEL$2的命名。
看來即使對於同樣的一個查詢語句,查詢塊的命名也可能出現不同。ORACLE根據最終轉換生成的語句來為最終的SQL生成一個查詢塊
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22034023/viewspace-715449/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Hibernate——Query查詢
- Laravel query when 的查詢Laravel
- Flashback Query閃回查詢
- 關於Parallel queryParallel
- Elasticsearch Query DSL查詢入門Elasticsearch
- 關於批次分頁查詢
- Oracle Flashback query查詢的侷限Oracle
- Mysql 查詢快取 query_cacheMySql快取
- 閃回版本查詢(Flashback Version Query)
- Laravel Query Builder 複雜查詢案例:子查詢實現分割槽查詢 partition byLaravelUI
- 檢查資料塊損壞(Block Corruption)BloC
- 通過 v$database_block_corruption 查詢資料檔案中的壞塊DatabaseBloC
- 關於oracle的空間查詢Oracle
- 關於index檔案呼叫查詢Index
- 閃回(關於閃回查詢)
- Elasticsearch複合查詢—constant score queryElasticsearch
- MySQL Slow Query log(慢查詢日誌)MySql
- MySQL slow query [慢查詢] 資料整理MySql
- 聊聊閃回版本查詢Flashback Version Query
- 聊聊閃回事務查詢Flashback Transaction Query
- 關於MySQL 通用查詢日誌和慢查詢日誌分析MySql
- 關於innodb中查詢的定位方法
- 關於mysql 子查詢中 使用 limitMySqlMIT
- 關於字串匹配查詢的總結字串匹配
- 關於Hibernate的查詢問題
- Android SQL資料庫查詢方法 query( )AndroidSQL資料庫
- 資料查詢語句:DQL(Data Query Language)
- 07.full text query_string查詢
- 【DG】Real-time query實時查詢操作
- Oracle並行操作——並行查詢(Parallel Query)Oracle並行Parallel
- 查詢快取(query_cache)的影響快取
- 關於mysql的query_cacheMySql
- PostgreSQL 原始碼解讀(20)- 查詢語句#5(查詢樹Query詳解)SQL原始碼
- Python—Django:關於在Django框架中對資料庫的查詢函式,查詢集和關聯查詢PythonDjango框架資料庫函式
- Tengine 如何查詢 server 塊Server
- 獲取查詢塊名字
- 如何查詢損壞塊
- 關於Ajax入門文章查詢看JavaEyeJava