看到一篇文章:在Oracle数据库中使用instr代替like实操(见http://www.linuxidc.com/Linux/2009-12/23599.htm),看到之后很质疑,以下是我做的简单测试,以对原文作对比验证。
1.创建索引前
SQL> select count(1) from t;
COUNT(1)
----------
11905920
Elapsed: 00:00:11.38
SQL> select count(1) from t where instr(object_name,'A') >0;
COUNT(1)
----------
3947520
Elapsed: 00:00:10.46
SQL> select count(1) from t where object_name like '%A%';
COUNT(1)
----------
3947520
Elapsed: 00:00:12.31
SQL> select count(1) from t where instr(object_name,'A') = 0;
COUNT(1)
----------
7958400
Elapsed: 00:00:10.39
SQL> select count(1) from t where object_name not like '%A%';
COUNT(1)
----------
7958400
Elapsed: 00:00:10.94