[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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20180509]函式索引問題.txt函式索引
- [20190827]函式索引與選擇率.txt函式索引
- [20190918]關於函式索引問題.txt函式索引
- [20241012]cursor_sharing=force與函式索引.txt函式索引
- [20180408]那些函式索引適合欄位的查詢.txt函式索引
- [20211231]ORA-01418 specified index does not exist.txtIndex
- 對Largest函式的測試函式
- [20211231]vim自動格式化sql語句.txtSQL
- [20211231]set linesize and dbms_output.line輸出問題.txt
- [20200213]函式nullif使用.txt函式Null
- Oracle索引梳理系列(六)- Oracle索引種類之函式索引Oracle索引函式
- Golang時間函式及測試函式執行時間案例Golang函式
- pytest標記:查詢測試策略、標記測試函式函式
- 第2章 編寫測試函式函式
- MySQL函式索引及優化MySql函式索引優化
- 說說在 Python 中如何測試函式Python函式
- [20231123]函式與bash shell呼叫.txt函式
- [20191002]函式dump的bug.txt函式
- [20190728]分析函式LAST_VALUE.txt函式AST
- [20190401]關於semtimedop函式呼叫.txt函式
- [20181002]DBMS_FLASHBACK與函式.txt函式
- [20180531]函式呼叫與遞迴.txt函式遞迴
- python+pytest介面自動化之測試函式、測試類/測試方法的封裝Python函式封裝
- python+pytest介面自動化(11)-測試函式、測試類/測試方法的封裝Python函式封裝
- C++ 虛解構函式簡單測試C++函式
- mysql 拾遺提高(函式、事務、索引)MySql函式索引
- C++ 成員函式指標簡單測試C++函式指標
- [20231204]建立監測索引ind_m.sql指令碼.txt索引SQL指令碼
- [20220531]測試quiz night.txtUI
- 資料型別與函式索引-Oracle篇資料型別函式索引Oracle
- 資料型別與函式索引-MySQL篇資料型別函式索引MySql
- 資料型別與函式索引-PostgreSQL篇資料型別函式索引SQL
- 用函式索引構造特殊的約束函式索引
- SQL優化案例-自定義函式索引(五)SQL優化函式索引
- Oracle優化案例-自定義函式索引(五)Oracle優化函式索引
- 【Mysql】資料庫索引,百萬資料測試索引效果MySql資料庫索引
- [20190402]關於semtimedop函式呼叫2.txt函式
- [20220603]測試quiz night(補充).txtUI