关于COUNT STOPKEY的工作机制(转载)

时间:2021-05-10 17:22:06

SQL> select rownum rn ,a.* from cnmir.ew_auctions a where rownum<50000;

Execution Plan
----------------------------------------------------------
Plan hash value: 721966694

----------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 49999 | 4833K| 163 (2)| 00:00:02 |
|* 1 | COUNT STOPKEY | | | | | |
| 2 | TABLE ACCESS FULL| EW_AUCTIONS | 49999 | 4833K| 163 (2)| 00:00:02 |
----------------------------------------------------------------------------------

SQL> select * from cnmir.ew_auctions where issue_id<80;

Execution Plan
----------------------------------------------------------
Plan hash value: 518049957

---------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 99 | 1379 (2)| 00:00:17 |
|* 1 | TABLE ACCESS FULL| EW_AUCTIONS | 1 | 99 | 1379 (2)| 00:00:17 |
---------------------------------------------------------------------------------

可见COUNT STOPKEY 机制是只针对rownum而设定的!