index skip scan 和oracle partition index 未加分区键类似

索引跳过扫描提升了对非前缀列的索引扫描,因为扫描索引块通常比扫描表数据块更快。非前缀索引是指其第一列不包含关键列的索引。

如果将前缀索引想象为类似分区表,
这个概念会更容易理解。在分区对象中,分区键(此处为首列)定义了存储在哪一列的分区数据中。在索引情况下,每个键下方的每一行(前缀列)都会在该键下排序。因此,在对前缀索引进行跳扫描时,前缀值被跳过,非前缀列作为逻辑子索引访问。后列在前缀列内排列,因此可以进行"正常"索引访问,而无需忽略前缀。
在这种情况下,复合指数被逻辑上拆分为更小的子指数。逻辑子索引的数量取决于初始列的基数。因此,即使首列未被用于 where 子句,也可以使用索引。

Applies To

All Users

Summary

This document explains the index skip scan hint usage.

For developers and DBAs who need to know the syntax of the index skip scan hint.

Solution

Index skip scans improve index scans against non-prefix columns since it is often faster to scan index blocks than scanning table data blocks. A non-prefix index is an index which does not contain a key column as its first column.

This concept is easier to understand if one imagines a prefix index to be similar to a partitioned table. In a partitioned object the partition key (in this case the leading column) defines which partition data is stored within. In the index case every row underneath each key (the prefix column) would be ordered under that key. Thus in a skip scan of a prefixed index, the prefixed value is skipped and the non-prefix columns are accessed as logical sub-indexes. The trailing columns are ordered within the prefix column and so a 'normal' index access can be done ignoring the prefix.

In this case a composite index is split logically into smaller subindexes. The number of logical subindexes depends on the cardinality of the initial column. Hence it is now possible to use the index even if the leading column is not used in a where clause.

++Example query and explain plan:++

drop table at2;
create table at2(a varchar2(3),b varchar2(10),c varchar2(5));

begin
for i in 1..1000
loop
insert into at2 values('M', i, 'M');
insert into at2 values('F', i, 'F');
end loop;
end;
/
create index at2_i on at2(a,b,c);
exec dbms_stats.gather_table_stats(OWNNAME => NULL, TABNAME => 'at2',
CASCADE => TRUE, method_opt => 'FOR ALL COLUMNS SIZE 1');

set autotrace traceonly
select * from at2 where b='352';


| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 2 | 14 | 3 (0)| 00:00:01 |
|* 1 | INDEX SKIP SCAN | AT2_I | 2 | 14 | 3 (0)| 00:00:01 |

Predicate Information (identified by operation id):

1 - access("B"='352')
filter("B"='352')

set autotrace off

相关推荐
AOwhisky1 天前
Redis 学习笔记(第一期):概述、安装配置与核心理论
运维·数据库·redis·笔记·学习·云计算
ytttr8731 天前
C# 定时数据库备份工具
开发语言·数据库·c#
睡不醒男孩0308231 天前
自建 Prometheus+Grafana 与 CLUP 深度监控 PG 集群有什么区别?
数据库·oracle
AOwhisky1 天前
Redis 学习笔记(第四期):高可用与集群(哨兵 + Cluster + 容器化)
linux·运维·数据库·redis·笔记·学习·缓存
猫猫聚会Ing1 天前
数据库设计 Prompt 提示词 - 构建与迭代
数据库
上海云盾-小余1 天前
源站隐藏实战:规避裸 IP 被直接攻击的完整方案
数据库·网络协议·tcp/ip
微学AI1 天前
时序大模型 TimechoAI 赋能工业时序数据底层技术优势与实操
数据库·大模型·时序大模型
北顾笙9801 天前
MYSQL-day03
数据库·sql·mysql
MXsoft6181 天前
**混合云统一监控实践:私有云+公有云的一体化运维方案**
运维·网络·数据库
瀚高PG实验室1 天前
java中间件无法连接数据库
java·数据库·中间件·瀚高数据库