index unique scan vs index full scan

本文详细解释了在数据库操作中使用唯一索引时的不同扫描方式,包括indexuniquescan、indexrangescan和indexfullscan,并通过具体示例说明如何进行有效查询。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

index unique scan ,是因为建了唯一索引, unique

如 :create unique index AA_INDEX on AA_TEST (SID, ITEMVALUE)

在执行语句中 where子句必须包括 唯一索引中的所有字段,而不用管select是否是索引中的字段.

analyze table aa_test compute statistics;

select sid,itemvalue from aa_test t where sid=1;

这个用 index range scan

select sid,itemvalue from aa_test t where itemvalue ='100';

这个用index full scan

也就是说如果在where子句中没有选择 唯一索引的前置索引字段,而是唯一索引的其他的字段,就会变成

index full scan

而对其他索引(不是唯一索引)中,只用索引中的某个字段(不是前置),只是 index range scan,不是index full scan,

从某些文档中知道 index full scan是index range scan的一个极限,当从index的叶子从左找到右时,就是index full scan.

下面是强制用 跳跃索引

select /*+ index_ss(aa_t inde_aa_t) */ aa_t.object_type
from aa_t where object_id =2

 

 

from :http://space.itpub.net/12712263/viewspace-606960

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值