[20211231]函数索引测试.txt --//开发在sql语句中使用10000000+ztbh之类的表达式,必须建立函数索引,测试看看ztbh+10000000之类的索引是否还可以使用. 1.环境: SCOTT@book> @ ver1 PORT_STRING VERSION BANNER ------------------------------ -------------- -------------------------------------------------------------------------------- x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production 2.测试: create table deptx as select * from dept; SCOTT@book> create index if_deptx_dept on deptx (1000+deptno); Index created. SCOTT@book> select * from deptx where deptno+1000=1010; DEPTNO DNAME LOC ---------- -------------- ------------- 10 ACCOUNTING NEW YORK SCOTT@book> @ dpc '' '' '' PLAN_TABLE_OUTPUT ------------------------------------- SQL_ID 5r5un34cwmsu5, child number 0 ------------------------------------- select * from deptx where deptno+1000=1010 Plan hash value: 4094583743 ---------------------------------------------------------------------------------------------- | Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time | ---------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 2 (100)| | | 1 | TABLE ACCESS BY INDEX ROWID| DEPTX | 1 | 20 | 2 (0)| 00:00:01 | |* 2 | INDEX RANGE SCAN | IF_DEPTX_DEPT | 1 | | 1 (0)| 00:00:01 | ---------------------------------------------------------------------------------------------- Query Block Name / Object Alias (identified by operation id): ------------------------------------------------------------- 1 - SEL$1 / DEPTX@SEL$1 2 - SEL$1 / DEPTX@SEL$1 Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("DEPTX"."SYS_NC00004$"=1010) SCOTT@book> select * from deptx where 1000+deptno=1010; DEPTNO DNAME LOC ---------- -------------- ------------- 10 ACCOUNTING NEW YORK SCOTT@book> @ dpc '' '' '' PLAN_TABLE_OUTPUT ------------------------------------- SQL_ID 52r3nzuy9tjx8, child number 0 ------------------------------------- select * from deptx where 1000+deptno=1010 Plan hash value: 4094583743 ---------------------------------------------------------------------------------------------- | Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time | ---------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 2 (100)| | | 1 | TABLE ACCESS BY INDEX ROWID| DEPTX | 1 | 20 | 2 (0)| 00:00:01 | |* 2 | INDEX RANGE SCAN | IF_DEPTX_DEPT | 1 | | 1 (0)| 00:00:01 | ---------------------------------------------------------------------------------------------- Query Block Name / Object Alias (identified by operation id): ------------------------------------------------------------- 1 - SEL$1 / DEPTX@SEL$1 2 - SEL$1 / DEPTX@SEL$1 Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("DEPTX"."SYS_NC00004$"=1010) --//可以使用我建立的函数索引。 select * from deptx where 999+1+deptno=1010; select * from deptx where deptno+1e3=1010; select * from deptx where 1e3+deptno=1010; --//也可以使用。但是减0,减其它不行,例子: SCOTT@book> select * from deptx where 1e3+deptno-0=1010; DEPTNO DNAME LOC ---------- -------------- ------------- 10 ACCOUNTING NEW YORK SCOTT@book> @ dpc '' '' PLAN_TABLE_OUTPUT ------------------------------------- SQL_ID 7j57j3ybzmfk9, child number 0 ------------------------------------- select * from deptx where 1e3+deptno-0=1010 Plan hash value: 428208148 ---------------------------------------------------------------------------- | Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time | ---------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 3 (100)| | |* 1 | TABLE ACCESS FULL| DEPTX | 1 | 24 | 3 (0)| 00:00:01 | ---------------------------------------------------------------------------- Query Block Name / Object Alias (identified by operation id): ------------------------------------------------------------- 1 - SEL$1 / DEPTX@SEL$1 Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter(1000+"DEPTNO"-0=1010) --//其它大家可以自行测试。
[20211231]函数索引测试.txt
来源:这里教程网
时间:2026-03-03 17:21:39
作者:
编辑推荐:
- [20211231]函数索引测试.txt03-03
- [20220102]使用ashtop与dashtop脚本的小问题.txt03-03
- [20220104]文件格式与sql_id计算.txt03-03
- 【ERROR】存储链路问题造成oracle错误,ora-600[4193] 问题处理03-03
- ORA-29770: global enqueue process LMON is hung03-03
- [20220104]in list 几种写法性能测试.txt03-03
- [20220105]建立非唯一主键对性能有影响吗.txt03-03
- [20220105]再论ORA-29275与toad 12.txt03-03
下一篇:
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
热文推荐
- 十个关于互联网圈的冷知识
十个关于互联网圈的冷知识
26-03-03 - Oracle:SCN
Oracle:SCN
26-03-03 - 内存卡视频删除后怎么恢复?三个步骤一看就会
内存卡视频删除后怎么恢复?三个步骤一看就会
26-03-03 - 批量锁(适用各种关系型数据库)
批量锁(适用各种关系型数据库)
26-03-03 - DATAGUARD配置参数详细解释
DATAGUARD配置参数详细解释
26-03-03 - 数据迁移
数据迁移
26-03-03 - 临时表空间ORA-1652问题解决
临时表空间ORA-1652问题解决
26-03-03 - 【CORE】在UNIX环境下从核心文件获取堆栈信息
【CORE】在UNIX环境下从核心文件获取堆栈信息
26-03-03 - 「Oracle」客户端 PL/SQL DEVELOPER 安装使用
「Oracle」客户端 PL/SQL DEVELOPER 安装使用
26-03-03 - Oracle的过载保护-数据库资源限制
Oracle的过载保护-数据库资源限制
26-03-03
