index range scan和index fast full scan

SQL> create index idx_1 on t1(object_id);

Index created.

SQL> set linesie 200
SP2-0158: unknown SET option "linesie"
SQL> select max(object_id) from t1;

MAX(OBJECT_ID)
--------------
	175920

SQL> select count(*) from t1 where object_id>170000;

  COUNT(*)
----------
      9696

SQL> set autot trace
SQL> select count(*) from t1 where object_id>170000;


Execution Plan
----------------------------------------------------------
Plan hash value: 3018594191

---------------------------------------------------------------------------
| Id  | Operation	  | Name  | Rows  | Bytes | Cost (%CPU)| Time	  |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |	  |	1 |    13 |    40   (0)| 00:00:01 |
|   1 |  SORT AGGREGATE   |	  |	1 |    13 |	       |	  |
|*  2 |   INDEX RANGE SCAN| IDX_1 | 20427 |   259K|    40   (0)| 00:00:01 |
---------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("OBJECT_ID">170000)

Note
-----
   - dynamic sampling used for this statement


Statistics
----------------------------------------------------------
	  0  recursive calls
	  0  db block gets
	 25  consistent gets
	  0  physical reads
	  0  redo size
	516  bytes sent via SQL*Net to client
	492  bytes received via SQL*Net from client
	  2  SQL*Net roundtrips to/from client
	  0  sorts (memory)
	  0  sorts (disk)
	  1  rows processed

SQL> select count(*) from t1 where object_id>170000;


Execution Plan
----------------------------------------------------------
Plan hash value: 3018594191

---------------------------------------------------------------------------
| Id  | Operation	  | Name  | Rows  | Bytes | Cost (%CPU)| Time	  |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |	  |	1 |	5 |   133   (1)| 00:00:02 |
|   1 |  SORT AGGREGATE   |	  |	1 |	5 |	       |	  |
|*  2 |   INDEX RANGE SCAN| IDX_1 | 55470 |   270K|   133   (1)| 00:00:02 |
---------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("OBJECT_ID">170000)


Statistics
----------------------------------------------------------
	  1  recursive calls
	  0  db block gets
	 25  consistent gets
	  0  physical reads
	  0  redo size
	516  bytes sent via SQL*Net to client
	492  bytes received via SQL*Net from client
	  2  SQL*Net roundtrips to/from client
	  0  sorts (memory)
	  0  sorts (disk)
	  1  rows processed

SQL> select count(*) from t1 where object_id>1;


Execution Plan
----------------------------------------------------------
Plan hash value: 1271403589

-------------------------------------------------------------------------------
| Id  | Operation	      | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------
|   0 | SELECT STATEMENT      |       |     1 |     5 |   865	(3)| 00:00:11 |
|   1 |  SORT AGGREGATE       |       |     1 |     5 | 	   |	      |
|*  2 |   INDEX FAST FULL SCAN| IDX_1 |  1648K|  8048K|   865	(3)| 00:00:11 |
-------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("OBJECT_ID">1)


Statistics
----------------------------------------------------------
	  1  recursive calls
	  0  db block gets
       3652  consistent gets
	522  physical reads
	  0  redo size
	518  bytes sent via SQL*Net to client
	492  bytes received via SQL*Net from client
	  2  SQL*Net roundtrips to/from client
	  0  sorts (memory)
	  0  sorts (disk)
	  1  rows processed


SQL> select count(*) from t1 where object_id>=170000;


Execution Plan
----------------------------------------------------------
Plan hash value: 3018594191

---------------------------------------------------------------------------
| Id  | Operation	  | Name  | Rows  | Bytes | Cost (%CPU)| Time	  |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |	  |	1 |	5 |   133   (1)| 00:00:02 |
|   1 |  SORT AGGREGATE   |	  |	1 |	5 |	       |	  |
|*  2 |   INDEX RANGE SCAN| IDX_1 | 55502 |   271K|   133   (1)| 00:00:02 |
---------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("OBJECT_ID">=170000)


Statistics
----------------------------------------------------------
	  1  recursive calls
	  0  db block gets
	 25  consistent gets
	  0  physical reads
	  0  redo size
	516  bytes sent via SQL*Net to client
	492  bytes received via SQL*Net from client
	  2  SQL*Net roundtrips to/from client
	  0  sorts (memory)
	  0  sorts (disk)
	  1  rows processed

原文地址:https://www.cnblogs.com/hzcya1995/p/13352014.html