【发布时间】:2010-12-24 08:07:45
【问题描述】:
如果我有一张桌子
create table sv ( id integer, data text )
还有一个索引:
create index myindex_idx on sv (id,text)
如果我进行查询,这仍然有用吗
select * from sv where id = 10
我问的原因是我正在查看一组没有任何索引的表,并看到选择查询的不同组合。有些只使用一列,而另一些则不止一列。我需要为这两个集合创建索引还是一个全包索引可以? 我正在添加索引以实现比全表扫描更快的查找。
示例(基于 Matt Huggins 的回答):
select * from table where col1 = 10
select * from table where col1 = 10 and col2=12
select * from table where col1 = 10 and col2=12 and col3 = 16
都可以被索引表(co1l1,col2,col3)覆盖,但是
select * from table where col2=12
需要另一个索引吗?
【问题讨论】:
-
我只是