In the case of like, there are two forms of writing that are based on a 5% assessment of the total data.
sql> drop table test purge;
sql> CREATE TABLE test as SELECT * from Dba_objects;
sql> exec dbms_stats.gather_table_stats (user, ' test ');
Sql> Select COUNT (1) from test;
COUNT (1)
----------
79747
Sql> Select COUNT (1) from the test where object_name like ' test% ';
COUNT (1)
----------
0
Sql> Select COUNT (1) from the test where object_name like '%test% ';
COUNT (1)
----------
12
Sql> Select COUNT (1) from the test where object_name like '%test ';
COUNT (1)
----------
2
sql> Set Autotrace trace exp
--79747*0.05=3987.35
Sql> SELECT * FROM test where object_name like '%test% ';
Execution plan
----------------------------------------------------------
Plan Hash value:1357081020
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU) | Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 3987 | 389k| 224 (1) | 00:00:04 |
|* 1 | TABLE ACCESS full| TEST | 3987 | 389k| 224 (1) | 00:00:04 |
--------------------------------------------------------------------------
predicate information (identified by Operation ID):
---------------------------------------------------
1-filter ("object_name" like '%test% ' and "object_name" are not NULL)
--79747*0.05=3987.35
Sql> SELECT * FROM test where object_name like '%test ';
Execution plan
----------------------------------------------------------
Plan Hash value:1357081020
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU) | Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 3987 | 389k| 224 (1) | 00:00:04 |
|* 1 | TABLE ACCESS full| TEST | 3987 | 389k| 224 (1) | 00:00:04 |
--------------------------------------------------------------------------
predicate information (identified by Operation ID):
---------------------------------------------------
1-filter ("object_name" like '%test ' and "object_name" are not NULL)
--If the percent sign is written in the back, you cannot follow the 5%
sql> select * from test where object_name like ' test% ';
Execution Plan
----------------------------------------------------------
Plan hash value:1357081020
-------- ------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU) | Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 200 | 224 (1) | 00:00:04 |
|* 1 | table ACCESS full| TEST | 2 | 200 | 224 (1) | 00:00:04 |
--------------------------------------------------------------------------
Predicate information ( identified by Operation ID):
---------------------------------------------------
1-filter (" object_name "like ' test% ')
Sql> SELECT * FROM test where object_name like ' t% ';
Execution plan
----------------------------------------------------------
Plan Hash value:1357081020
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU) | Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1079 | 105k| 224 (1) | 00:00:04 |
|* 1 | TABLE ACCESS full| TEST | 1079 | 105k| 224 (1) | 00:00:04 |
--------------------------------------------------------------------------
predicate information (identified by Operation ID):
---------------------------------------------------
1-filter ("object_name" like ' t% ')
Oracle CBO evaluates the amount of like data