当前位置:网站首页>Analysis of unused index columns caused by implicit conversion of timestamp
Analysis of unused index columns caused by implicit conversion of timestamp
2022-04-23 13:43:00 【Not dizzy yet】
After the business table of a system is rebuilt , The next day, the user reported that the business system was slow , Check performance data , Discover business SQL The execution efficiency of , In depth analysis found that timestamp Data columns , Index not used on column ; Through the analysis of the implementation plan , It can be found that there is an implicit conversion ; That is to use idtime > systimestamp; when , What is actually carried out is filter(SYS_EXTRACT_UTC(INTERNAL_FUNCTION("CREATION_DATE"))>TIMESTAMP' 2022-03-14 00:17:35.520486000');
MOS Document Index on a Timestamp Column Cannot be Accessed Properly (Doc ID 1321016.1) Having said this question , The solution given is : Change the column to "timestamp with time zone", then a function-based index is automatically created when you create index on this column. That is, change the field type of the time column to "timestamp with time zone", This will automatically create a function index column .
We directly create a functional index column manually CREATE INDEX "abc"."abc_OBJECT_MAP_N1_FUNCTION" ON "abc"."abc_OBJECT_MAP" (SYS_EXTRACT_UTC("CREATION_DATE")) local online;, Then you can use the index ,SQL Efficiency returns to normal .
=====1. Use to_date The sentence of :
select count(*) from abc.abc_OBJECT_MAP where creation_date>to_date('20110312 22:00', 'yyyymmdd hh24:mi')
COUNT(*)
----------
7
Execution Plan
----------------------------------------------------------
Plan hash value: 4292575048
------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 13 | 4 (0)| 00:00:01 | | |
| 1 | SORT AGGREGATE | | 1 | 13 | | | | |
| 2 | PARTITION RANGE ALL | | 7 | 91 | 4 (0)| 00:00:01 | 1 |1048575|
|* 3 | INDEX FAST FULL SCAN| abc_OBJECT_MAP_N1 | 7 | 91 | 4 (0)| 00:00:01 | 1 |1048575|
------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - filter("CREATION_DATE">TIMESTAMP' 2011-03-12 22:00:00')
##########
=====2. Use TIMESTAMP The sentence of :
SQL> select count(*) from abc.abc_OBJECT_MAP where creation_date>TIMESTAMP'2022-03-14 00:17:35.520486 +00:00';
COUNT(*)
----------
4
Execution Plan
----------------------------------------------------------
Plan hash value: 413461469
-------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
-------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 13 | 38 (0)| 00:00:01 | | |
| 1 | SORT AGGREGATE | | 1 | 13 | | | | |
| 2 | PARTITION RANGE ALL| | 5 | 65 | 38 (0)| 00:00:01 | 1 |1048575|
|* 3 | TABLE ACCESS FULL | abc_OBJECT_MAP | 5 | 65 | 38 (0)| 00:00:01 | 1 |1048575|
-------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - filter(SYS_EXTRACT_UTC(INTERNAL_FUNCTION("CREATION_DATE"))>TIMESTAMP' 2022-03-14
00:17:35.520486000')
########################
After indexing :
SQL> CREATE INDEX "abc"."abc_OBJECT_MAP_N1_FUNCTION" ON "abc"."abc_OBJECT_MAP" (SYS_EXTRACT_UTC("CREATION_DATE")) local online;
Index created.
SQL> select index_name,index_type from dba_indexes where table_name='abc_OBJECT_MAP';
INDEX_NAME INDEX_TYPE
------------------------------ ---------------------------
SYS_IL0000074117C00002$$ LOB
abc_OBJECT_MAP_N1 NORMAL
HOM_N2 NORMAL
abc_OBJECT_MAP_N1_FUNCTION FUNCTION-BASED NORMAL ====>>> Function index
PK_abc_OBJECT_MAP NORMAL
SQL> select segment_name,PARTITION_NAME ,SEGMENT_TYPE,TABLESPACE_NAME from dba_segments where segment_name='abc_OBJECT_MAP_N1_FUNCTION';
SEGMENT_NAME PARTITION_NAME SEGMENT_TYPE TABLESPACE_NAME
------------------------------ -------------------- ------------------ ------------------------------
abc_OBJECT_MAP_N1_FUNCTION SYS_P605 INDEX PARTITION USERS
abc_OBJECT_MAP_N1_FUNCTION SYS_P608 INDEX PARTITION USERS
abc_OBJECT_MAP_N1_FUNCTION SYS_P602 INDEX PARTITION USERS
abc_OBJECT_MAP_N1_FUNCTION SYS_P584 INDEX PARTITION USERS
abc_OBJECT_MAP_N1_FUNCTION SYS_P587 INDEX PARTITION USERS
abc_OBJECT_MAP_N1_FUNCTION SYS_P614 INDEX PARTITION USERS
abc_OBJECT_MAP_N1_FUNCTION SYS_P611 INDEX PARTITION USERS
===
=====3. Use to_date The sentence of :
SQL> select count(*) from abc.abc_OBJECT_MAP where creation_date>to_date('20110312 22:00', 'yyyymmdd hh24:mi');
COUNT(*)
----------
7
Execution Plan
----------------------------------------------------------
Plan hash value: 4292575048
------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 13 | 4 (0)| 00:00:01 | | |
| 1 | SORT AGGREGATE | | 1 | 13 | | | | |
| 2 | PARTITION RANGE ALL | | 7 | 91 | 4 (0)| 00:00:01 | 1 |1048575|
|* 3 | INDEX FAST FULL SCAN| abc_OBJECT_MAP_N1 | 7 | 91 | 4 (0)| 00:00:01 | 1 |1048575|
------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - filter("CREATION_DATE">TIMESTAMP' 2011-03-12 22:00:00')
=====4. Use TIMESTAMP The sentence of :
SQL> select count(*) from abc.abc_OBJECT_MAP where creation_date>TIMESTAMP'2022-03-14 00:17:35.520486 +00:00';
COUNT(*)
----------
4
Execution Plan
----------------------------------------------------------
Plan hash value: 1155152824
-------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
-------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 13 | 4 (0)| 00:00:01 | | |
| 1 | SORT AGGREGATE | | 1 | 13 | | | | |
| 2 | PARTITION RANGE ALL| | 4 | 52 | 4 (0)| 00:00:01 | 1 |1048575|
|* 3 | INDEX RANGE SCAN | abc_OBJECT_MAP_N1_FUNCTION | 4 | 52 | 4 (0)| 00:00:01 | 1 |1048575|
-------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access(SYS_EXTRACT_UTC(INTERNAL_FUNCTION("CREATION_DATE"))>TIMESTAMP' 2022-03-14
00:17:35.520486000')
版权声明
本文为[Not dizzy yet]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230601579508.html
边栏推荐
- SAP ui5 application development tutorial 72 - trial version of animation effect setting of SAP ui5 page routing
- What do the raddr and rport in webrtc ice candidate mean?
- Special window function rank, deny_ rank, row_ number
- TERSUS笔记员工信息516-Mysql查询(2个字段的时间段唯一性判断)
- Oracle clear SQL cache
- 【重心坐标插值、透视矫正插值】原理以及用法见解
- 软考系统集成项目管理工程师全真模拟题(含答案、解析)
- Part 3: docker installing MySQL container (custom port)
- Ai21 labs | standing on the shoulders of giant frozen language models
- What does the SQL name mean
猜你喜欢
Unified task distribution scheduling execution framework
Double pointer instrument panel reading (I)
Tersus notes employee information 516 MySQL query (time period uniqueness judgment of 2 fields)
Dolphin scheduler scheduling spark task stepping record
RTOS mainstream assessment
SAP UI5 应用开发教程之七十二 - SAP UI5 页面路由的动画效果设置
Window analysis function last_ VALUE,FIRST_ VALUE,lag,lead
[point cloud series] summary of papers related to implicit expression of point cloud
[point cloud series] foldingnet: point cloud auto encoder via deep grid deformation
Oracle defines self incrementing primary keys through triggers and sequences, and sets a scheduled task to insert a piece of data into the target table every second
随机推荐
Oracle lock table query and unlocking method
Machine learning -- PCA and LDA
Dolphin scheduler configuring dataX pit records
Oracle and MySQL batch query all table names and table name comments under users
kettle庖丁解牛第16篇之输入组件周边讲解
Common commands of ADB shell
Oracle database combines the query result sets of multiple columns into one row
Using open to open a file in JNI returns a - 1 problem
[machine learning] Note 4. KNN + cross validation
面试官给我挖坑:单台服务器并发TCP连接数到底可以有多少 ?
Information: 2021 / 9 / 29 10:01 - build completed with 1 error and 0 warnings in 11S 30ms error exception handling
Oracle creates tablespaces and modifies user default tablespaces
MySQL and PgSQL time related operations
Campus takeout system - "nongzhibang" wechat native cloud development applet
[andorid] realize SPI communication between kernel and app through JNI
Machine learning -- naive Bayes
[point cloud series] foldingnet: point cloud auto encoder via deep grid deformation
Test the time required for Oracle library to create an index with 7 million data in a common way
Oracle modify default temporary tablespace
According to the salary statistics of programmers in June 2021, the average salary is 15052 yuan. Are you holding back?