SQL> var x1 number;
SQL> exec :x1 :=1;
PL/SQL 过程已成功完成。
SQL> set autot on
SQL> set autot traceonly
SQL> select count(*) from t where object_id =:x1 or :x1=0;
执行计划
----------------------------------------------------------
Plan hash value: 2966233522
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 3 | 278 (1)| 00:00:04 |
| 1 | SORT AGGREGATE | | 1 | 3 | | |
|* 2 | TABLE ACCESS FULL| T | 761 | 2283 | 278 (1)| 00:00:04 |
---------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter(TO_NUMBER(:X1)=0 OR "OBJECT_ID"=TO_NUMBER(:X1))
统计信息
----------------------------------------------------------
223 recursive calls
0 db block gets
1050 consistent gets
1014 physical reads
0 redo size
418 bytes sent via SQL*Net to client
416 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
5 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> select count(object_id) from t where object_id =:x1 or :x1=0;
执行计划
----------------------------------------------------------
Plan hash value: 3028837625
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 3 | 108 (1)| 00:00:02 |
| 1 | SORT AGGREGATE | | 1 | 3 | | |
|* 2 | INDEX FAST FULL SCAN| I_ID | 761 | 2283 | 108 (1)| 00:00:02 |
-----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter(TO_NUMBER(:X1)=0 OR "OBJECT_ID"=TO_NUMBER(:X1))
统计信息
----------------------------------------------------------
99 recursive calls
0 db block gets
406 consistent gets
389 physical reads
0 redo size
1 rows processed
SQL> select object_id from t where object_id =:x1 or :x1=0;
未选定行
执行计划
----------------------------------------------------------
Plan hash value: 1601196873
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 761 | 2283 | 278 (1)| 00:00:04 |
|* 1 | TABLE ACCESS FULL| T | 761 | 2283 | 278 (1)| 00:00:04 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(TO_NUMBER(:X1)=0 OR "OBJECT_ID"=TO_NUMBER(:X1))
SQL> select object_id from t where object_id =:x1 and :x1=0;
未选定行
执行计划
----------------------------------------------------------
Plan hash value: 845274062
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 73 | 219 | 1 (0)| 00:00:01 |
|* 1 | FILTER | | | | | |
|* 2 | INDEX RANGE SCAN| I_ID | 73 | 219 | 1 (0)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(TO_NUMBER(:X1)=0)
2 - access("OBJECT_ID"=TO_NUMBER(:X1))
SQL> select object_id from t where object_id =:x1
2 union
3 select object_id from t where 0 =:x1;
未选定行
执行计划
----------------------------------------------------------
Plan hash value: 2897536294
-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 68940 | 201K| | 467 (100)| 00:00:06 |
| 1 | SORT UNIQUE | | 68940 | 201K| 1640K| 467 (100)| 00:00:06 |
| 2 | UNION-ALL | | | | | | |
|* 3 | INDEX RANGE SCAN | I_ID | 73 | 219 | | 1 (0)| 00:00:01 |
|* 4 | FILTER | | | | | | |
| 5 | TABLE ACCESS FULL| T | 68867 | 201K| | 277 (1)| 00:00:04 |
-------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("OBJECT_ID"=TO_NUMBER(:X1))
4 - filter(TO_NUMBER(:X1)=0)
SQL> set linesize 999
SQL> select object_id from t where object_id =:x1
2 union
3 select object_id from t where 0 =:x1;
未选定行
执行计划
----------------------------------------------------------
Plan hash value: 2897536294
-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 68940 | 201K| | 467 (100)| 00:00:06 |
| 1 | SORT UNIQUE | | 68940 | 201K| 1640K| 467 (100)| 00:00:06 |
| 2 | UNION-ALL | | | | | | |
|* 3 | INDEX RANGE SCAN | I_ID | 73 | 219 | | 1 (0)| 00:00:01 |
|* 4 | FILTER | | | | | | |
| 5 | TABLE ACCESS FULL| T | 68867 | 201K| | 277 (1)| 00:00:04 |
-------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("OBJECT_ID"=TO_NUMBER(:X1))
4 - filter(TO_NUMBER(:X1)=0)
SQL> set linesize 130
SQL> select object_id from t where object_id =:x1
2 union
3 select object_id from t where 0 =:x1;
未选定行
执行计划
----------------------------------------------------------
Plan hash value: 2897536294
-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 68940 | 201K| | 467 (100)| 00:00:06 |
| 1 | SORT UNIQUE | | 68940 | 201K| 1640K| 467 (100)| 00:00:06 |
| 2 | UNION-ALL | | | | | | |
|* 3 | INDEX RANGE SCAN | I_ID | 73 | 219 | | 1 (0)| 00:00:01 |
|* 4 | FILTER | | | | | | |
| 5 | TABLE ACCESS FULL| T | 68867 | 201K| | 277 (1)| 00:00:04 |
-------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("OBJECT_ID"=TO_NUMBER(:X1))
4 - filter(TO_NUMBER(:X1)=0)
SQL> var x2 number;
SQL> exec :x2 :=4;
PL/SQL 过程已成功完成。
SQL> select object_id from t where object_id= :x1 or object_id =:x2;
执行计划
----------------------------------------------------------
Plan hash value: 547095368
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 146 | 438 | 3 (0)| 00:00:01 |
| 1 | INLIST ITERATOR | | | | | |
|* 2 | INDEX RANGE SCAN| I_ID | 146 | 438 | 3 (0)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("OBJECT_ID"=TO_NUMBER(:X1) OR "OBJECT_ID"=TO_NUMBER(:X2))
SQL> select object_id from t where object_id= :x1 or 3 =:x2;
未选定行
执行计划
----------------------------------------------------------
Plan hash value: 1601196873
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 761 | 2283 | 278 (1)| 00:00:04 |
|* 1 | TABLE ACCESS FULL| T | 761 | 2283 | 278 (1)| 00:00:04 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(TO_NUMBER(:X2)=3 OR "OBJECT_ID"=TO_NUMBER(:X1))
SQL> select object_id from t where object_id= :x1 or :x2=4;
已选择68867行。
执行计划
----------------------------------------------------------
Plan hash value: 1601196873
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 761 | 2283 | 278 (1)| 00:00:04 |
|* 1 | TABLE ACCESS FULL| T | 761 | 2283 | 278 (1)| 00:00:04 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(TO_NUMBER(:X2)=4 OR "OBJECT_ID"=TO_NUMBER(:X1))
SQL> select object_id from t where object_id= :x1 or :x1=0;
未选定行
执行计划
----------------------------------------------------------
Plan hash value: 1601196873
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 761 | 2283 | 278 (1)| 00:00:04 |
|* 1 | TABLE ACCESS FULL| T | 761 | 2283 | 278 (1)| 00:00:04 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(TO_NUMBER(:X1)=0 OR "OBJECT_ID"=TO_NUMBER(:X1)