当前位置:网站首页>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
边栏推荐
- MySQL and PgSQL time related operations
- [barycentric coordinate interpolation, perspective correction interpolation] principle and usage opinions
- PG library checks the name
- Generate 32-bit UUID in Oracle
- RTOS mainstream assessment
- Modification of table fields by Oracle
- PG SQL intercepts the string to the specified character position
- Zero copy technology
- AI21 Labs | Standing on the Shoulders of Giant Frozen Language Models(站在巨大的冷冻语言模型的肩膀上)
- Dolphin scheduler configuring dataX pit records
猜你喜欢
[point cloud series] learning representations and generative models for 3D point clouds
Window analysis function last_ VALUE,FIRST_ VALUE,lag,lead
联想拯救者Y9000X 2020
【视频】线性回归中的贝叶斯推断与R语言预测工人工资数据|数据分享
为什么从事云原生开发需要学习容器技术
Plato farm, a top-level metauniverse game, has made frequent positive moves recently
[Journal Conference Series] IEEE series template download guide
浅谈js正则之test方法bug篇
Cross carbon market and Web3 to achieve renewable transformation
[point cloud series] pointfilter: point cloud filtering via encoder decoder modeling
随机推荐
What does the SQL name mean
ACFs file system creation, expansion, reduction and other configuration steps
Comparison and summary of applicable scenarios of Clickhouse and MySQL database
[multi screen interaction] realize dual multi screen display II: startactivity mode
Example of specific method for TIA to trigger interrupt ob40 based on high-speed counter to realize fixed-point machining action
Operations related to Oracle partition
Oracle renames objects
Error 403 in most cases, you or one of your dependencies are requesting
Riscv MMU overview
TCP 复位gongji原理和实战复现
PG SQL intercepts the string to the specified character position
TCP reset Gongji principle and actual combat reproduction
爱可可AI前沿推介 (4.23)
Feature Engineering of interview summary
[point cloud series] full revolutionary geometric features
[official announcement] Changsha software talent training base was established!
Oracle kills the executing SQL
Campus takeout system - "nongzhibang" wechat native cloud development applet
为什么从事云原生开发需要学习容器技术
Machine learning -- model optimization