空华三界。如风卷烟。 幻影六塵。犹汤沃雪。 廓然無际。唯一真心。

How to design index

上一篇 / 下一篇  2008-04-03 02:11:51

How to design index


Index design:
1) Think of which columns should be included.
unique column to enable index unique scan
most queried columns to enable index full scan or fast index full scan

2) Think of the order of the columns in the index.
Use the most popular column order in query to avoid to sort during the query

3) Think of the DESCEND attribution of the column in the index.
To avoid to sort in desc, you need to define the column with desc during index creation

4) Think of the cluster factor of index
The lower of the cluster factor, the faster of the full table scan/index (fast) full scan

中文版:

1。 考虑要包含哪些字段。
在unique key上建立索引有利与进行index unique scan
对于定义了很多字段的表,如复合索引的建立应包含最常查询的字段,有这样有利与查询使用index full scan和index fast full scan来代替full table scan

2。考虑字段在索引中的位置。
字段在索引中的位置决定了使用该索引的查询的数据输出顺序。因此按经常出现在order by中字段的顺序来建立索引,有利与避免不必要的排序,减少不必要的I/O

3. 考虑索引中字段的DESCEND属性。
往往在查询最近的十条记录时会使用倒序,因此正确的设置DESCEND属性,有利与减少排序。

4。考虑索引的cluster factor.
Cluster factor越小,表明被索引字段的相似数据的物理位置越集中,而用来读取数据所需的I/O则越少。


TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

我的栏目

日历

« 2008-12-05  
 123456
78910111213
14151617181920
21222324252627
28293031   

数据统计

  • 访问量: 1195
  • 日志数: 950
  • 建立时间: 2008-03-22
  • 更新时间: 2008-04-20

RSS订阅

Open Toolbar