覆盖索引
来源:互联网 发布:金义网络经济学院 编辑:程序博客网 时间:2024/04/28 09:45
覆盖索引(covering indexex):一个索引包含了(或覆盖了)满足查询结果的数据
如:
create tableorders
(
id int identity(1, 1),
customer_id int,
product_id int,
quantity int
primary key (id)
)
go
create table product
(
id int identity(1, 1),
product_name varchar(30)
)
go
--创建覆盖索引
create index idx on orders(id, customer_id, product_id, quantity)
go
insert into orders
select 2001, 1, 100
go
insert into product
select '机器'
go
set showplan_text on
go
select o.id, o.customer_id, o.product_id, o.quantity
from orders o
where o.id = 1
go
select o.id, p.product_name, o.quantity
from orders o
inner join product p on p.id = o.product_id
where o.id = 1
go
set showplan_text off
上列中因为访问orders使用所覆盖索引,所以不会再去访问orders的实际表,如果此时orders在其它进程中处于写入状态也不会对orders的覆盖索引访问产生阻塞,记住两点:
- 写操作时,不会对相关的索引加锁,而只会对相关的数据加锁。
- 读操作时,只会对其访问路径中发现和使用的对象加锁(例如索引、数据行等)。
相关细节参见:http://www.zxbc.cn/html/20080726/63700_6.html
- 覆盖索引
- 索引覆盖
- 覆盖索引
- 覆盖索引
- 索引覆盖
- 覆盖索引
- 覆盖索引
- 覆盖索引VS非覆盖索引
- limit 覆盖索引优化
- 索引覆盖分析
- mysql覆盖索引
- Mysql覆盖索引
- MySQL覆盖索引
- mysql覆盖索引
- mysql覆盖索引
- SQL Server 覆盖索引
- Mysql-索引覆盖
- 《MySql》--覆盖索引
- 水晶报表控制分页
- 网站枢纽字
- SQL Server 四种隔离级别
- 水晶报表显示图片
- C++编译器如何实现异常处理
- 覆盖索引
- ORACLE异常处理总结
- 条款52:写了placement new也要写placement delete
- 水晶报表注册码
- 《监控》之胡哥
- 使用BackgroundWorker组件进行异步操作编程
- 针式打印机走纸控制
- 新手报道!!!
- 事件与委托