[20211231]函式索引測試.txt
[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)
--//其它大家可以自行測試。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2850478/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 測試建立基於函式的索引函式索引
- [20120612]函式索引中使用substr函式.txt函式索引
- [20170402]函式索引standard_hash.txt函式索引
- [20180509]函式索引問題.txt函式索引
- [20180212]函式索引問題.txt函式索引
- 對Largest函式的測試函式
- 測試 JavaScript 函式的效能JavaScript函式
- oracle函式測試小記Oracle函式
- [20190827]函式索引與選擇率.txt函式索引
- 函式索引陷阱函式索引
- oracle函式索引Oracle函式索引
- 函式索引使用細節——自定義函式的索引化函式索引
- 測試TOM=SQLLDR函式使用1SQL函式
- [20190918]關於函式索引問題.txt函式索引
- [20171202]關於函式索引的狀態.txt函式索引
- Oracle之函式索引Oracle函式索引
- 說說函式索引函式索引
- 索引中使用函式索引函式
- 第2章 編寫測試函式函式
- MySQL字元函式的壓力測試MySql字元函式
- ORACLE FUNCTION函式中DETERMINISTIC測試OracleFunction函式
- [20150803]使用函式索引注意的問題.txt函式索引
- Golang時間函式及測試函式執行時間案例Golang函式
- MySQL索引效能測試MySql索引
- pytest標記:查詢測試策略、標記測試函式函式
- 基於函式的索引函式索引
- 函式索引的問題函式索引
- deterministic function 函式索引Function函式索引
- 函式索引的儲存函式索引
- SQL優化--函式索引SQL優化函式索引
- sequence 和索引函式呼叫索引函式
- 管道函式及表函式的測試PIPELINED__PIPE ROW函式
- [20241012]cursor_sharing=force與函式索引.txt函式索引
- VC程式執行時間測試函式C程式函式
- [20180408]那些函式索引適合欄位的查詢.txt函式索引
- Oracle索引梳理系列(六)- Oracle索引種類之函式索引Oracle索引函式
- 說說在 Python 中如何測試函式Python函式
- 測試TOM=SQLLDR使用函式載入資料SQL函式