Oracle的文档上描述,当不包含SAMPLE语句的时候,可以使用HINT来指定执行计划,实际上即使包含SAMPLE语句,HINT也是生效的。
SQL> SELECT OBJECT_ID FROM T SAMPLE (1) WHERE WNER = USER;
OBJECT_ID
----------
60607
70958
执行计划
----------------------------------------------------------
Plan hash value: 3630032853
-------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 22 | 506 | 6 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 22 | 506 | 6 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IND_T_OWNER | 22 | | 5 (0)| 00:00:01 |
-------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("OWNER"=USER@!)
filter(ORA_HASH(ROWID,0,2211694651,'SYS_SAMPLE',0)<42949673)
统计信息
----------------------------------------------------------
0 recursive calls
0 db block gets
6 consistent gets
4 physical reads
0 redo size
452 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
2 rows processed
SQL> SELECT /*+ FULL(T) */ OBJECT_ID FROM T SAMPLE (1) WHERE WNER = USER;
未选定行
执行计划
----------------------------------------------------------
Plan hash value: 2767392432
本栏目更多精彩内容:http://www.bianceng.cn/database/Oracle/
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 22 | 506 | 158 (2)| 00:00:02 |
|* 1 | TABLE ACCESS SAMPLE| T | 22 | 506 | 158 (2)| 00:00:02 |
----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("OWNER"=USER@!)
统计信息
----------------------------------------------------------
1 recursive calls
0 db block gets
517 consistent gets
430 physical reads
0 redo size