[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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql條件查詢MySql
- MongoDB查詢條件MongoDB
- Laravel 多條件查詢Laravel
- SpringBoot Jpa多條件查詢Spring Boot
- AntDesignBlazor示例——列表查詢條件Blazor
- golang beego orm 查詢條件 or andGolangORM
- Javaweb-DQL-條件查詢JavaWeb
- 查詢條件封裝物件封裝物件
- mongodb條件查詢不等於MongoDB
- 【mybatis-plus】條件查詢MyBatis
- 寫一個“特殊”的查詢構造器 – (四、條件查詢:複雜條件)
- 20240719資料庫關聯查詢、條件查詢資料庫
- 34. 過濾條件、多表查詢、子查詢
- Linq查詢之多個排序條件排序
- Linq兩個from查詢條件
- 菜品條件分頁查詢
- hyperf關聯模型條件查詢模型
- mysql拆分字串做條件查詢MySql字串
- SQL-基礎語法 - 條件查詢 - 模糊查詢SQL
- mysql多條件過濾查詢之mysq高階查詢MySql
- MybatisPlus入門(五)MybatisPlus條件查詢MyBatis
- Vue請求介面查詢條件拼接Vue
- mybatis-plus QueryWrapper條件查詢器MyBatisAPP
- [20180625]函式與標量子查詢13(補充)函式
- mysql like查詢 - 根據多個條件的模糊匹配查詢MySql
- 查詢條件和條數,先查詢兩條免費的,後面為vip
- 深入理解mongodb查詢條件語句MongoDB
- [20190502]查詢條件不等於測試.txt
- ORACLE 查詢條件出現關鍵字:&Oracle
- 讓NoSQL支援簡單條件查詢VRSQLVR
- gorm 使用map實現in 條件查詢用法GoORM
- jsp+servlet+mysql多條件模糊查詢JSServletMySql
- SpringBoot學習筆記13——MybatisPlus條件查詢Spring Boot筆記MyBatis
- mysql,where條件查詢等學習筆記MySql筆記
- JN專案-時間查詢條件驗證
- mybatis lambdaQuery 查詢條件導致空指標MyBatis指標
- 報表查詢條件的 N 種使用方式
- MySQL全面瓦解7:查詢的過濾條件MySql