millerrch 发表于 2012-05-25 10:55

复合索引中的字段是不是leading column of an index 有什么区别?

本帖最后由 millerrch 于 2012-05-25 10:58 编辑

今儿用TOAD建复合索引的时候发现选择字段时有这个提示,还有对应的Nonleadingcolumn of an index

查了下解释
A leading portion of an index is a set of one or more columns that were specified first and consecutively in the list of columns in the CREATE INDEX statement that created the index. Consider this CREATE INDEX statement:

CREATE INDEX comp_ind ON table1(x, y, z);

x, xy, and xyz combinations of columns are leading portions of the index
yz, y, and z combinations of columns are not leading portions of the index

想问下这两种有什么区别?是说如果是leading index的话就算单独引用也能起效么?比如示例中,条件查询时只用到了x或者xy,索引也能起效?而非前置索引就不行了?ORACLE在查索引的时候自动根据头一个条件来进行匹配?

求教各位大侠····


目前表一共有20多个字段,其中会用作查询条件的有七八个字段,基本上是排列组合的形式来选择条件,可以任选其中几个,也可以选择其中某一个,目前最多把时间的字段可以作为强制必选项,其他的字段没法做成必选,所有发愁怎么建立索引,是复合索引好还是干脆各自建单独的索引?
页: [1]
查看完整版本: 复合索引中的字段是不是leading column of an index 有什么区别?