[20180625]10g下查詢條件rownum = 0.txt
[20180625]10g下查詢條件rownum = 0.txt
SCOTT@test> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- ----------------------------------------------------------------
x86_64/Linux 2.4.xx 10.2.0.4.0 Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
SCOTT@test> alter session set statistics_level=all;
Session altered.
SCOTT@test> select * from emp where rownum = 0;
no rows selected
SCOTT@test> @ &r/dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID 9cqutphfzqcdr, child number 1
-------------------------------------
select * from emp where rownum = 0
Plan hash value: 2063368778
----------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time | A-Rows | A-Time | Buffers |
----------------------------------------------------------------------------------------------------------------------
| 1 | COUNT | | 1 | | | | | 0 |00:00:00.01 | 7 |
|* 2 | FILTER | | 1 | | | | | 0 |00:00:00.01 | 7 |
| 3 | TABLE ACCESS FULL| EMP | 1 | 14 | 518 | 3 (0)| 00:00:01 | 14 |00:00:00.01 | 7 |
----------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1
3 - SEL$1 / EMP@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter(ROWNUM=0)
25 rows selected.
--//可以發現實際上真實做的是全表掃描,邏輯讀7,採用的是filter.
--//可以發現這個是一個bug,結果大量的邏輯讀.可以在11g重複測試:
SCOTT@book> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
SCOTT@book> alter session set statistics_level=all;
Session altered.
SCOTT@book> select * from emp where rownum = 0;
no rows selected
SCOTT@book> @ &r/dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID 9cqutphfzqcdr, child number 0
-------------------------------------
select * from emp where rownum = 0
Plan hash value: 1973284518
-----------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time | A-Rows | A-Time |
-----------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | | 2 (100)| | 0 |00:00:00.01 |
|* 1 | COUNT STOPKEY | | 1 | | | | | 0 |00:00:00.01 |
| 2 | TABLE ACCESS FULL| EMP | 1 | 1 | 38 | 2 (0)| 00:00:01 | 0 |00:00:00.01 |
-----------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1
2 - SEL$1 / EMP@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(ROWNUM=0)
25 rows selected.
--//這裡邏輯讀是0,A-rows=0(id=2),也說明沒有做全表掃描.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2156593/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 查詢條件為ROWNUM=1仍產生長時間等待
- FORM 10g的限制查詢條件引數ORM
- MongoDB查詢條件MongoDB
- MongoDB條件查詢MongoDB
- mysql條件查詢MySql
- 轉楊大師_查詢條件為ROWNUM=1仍產生長時間等待
- Laravel 多條件查詢Laravel
- SQL多條件查詢SQL
- 條件查詢JSPJS
- mongodb條件查詢不等於MongoDB
- golang beego orm 查詢條件 or andGolangORM
- 【mybatis-plus】條件查詢MyBatis
- 多條件查詢---ssh版本
- sql 查詢條件問題SQL
- 查詢條件封裝物件封裝物件
- Javaweb-DQL-條件查詢JavaWeb
- 寫一個“特殊”的查詢構造器 – (四、條件查詢:複雜條件)
- 34. 過濾條件、多表查詢、子查詢
- mysql拆分字串做條件查詢MySql字串
- AntDesignBlazor示例——列表查詢條件Blazor
- 查詢作為條件的SQLSQL
- 菜品條件分頁查詢
- Linq查詢之多個排序條件排序
- Linq兩個from查詢條件
- 複合條件查詢的重構
- oracle date資料的條件查詢Oracle
- 【索引】反向索引--條件 範圍查詢索引
- SQL SERVER 條件語句的查詢SQLServer
- SpringBoot Jpa多條件查詢Spring Boot
- Vue請求介面查詢條件拼接Vue
- mysql多條件過濾查詢之mysq高階查詢MySql
- mysql like查詢 - 根據多個條件的模糊匹配查詢MySql
- WF-1 FIND NOTIFICATION 下組合條件查詢無結果
- 查詢條件和條數,先查詢兩條免費的,後面為vip
- 深入理解mongodb查詢條件語句MongoDB
- mybatis-plus QueryWrapper條件查詢器MyBatisAPP
- gorm 使用map實現in 條件查詢用法GoORM
- 讓NoSQL支援簡單條件查詢VRSQLVR