- 最后登录
- 2014-7-8
- 在线时间
- 76 小时
- 威望
- 0
- 金钱
- 611
- 注册时间
- 2013-2-20
- 阅读权限
- 10
- 帖子
- 15
- 精华
- 0
- 积分
- 0
- UID
- 925
|
3#
发表于 2013-5-17 09:16:26
最近正在看concept 11203
Index Skip Scan An index skip scan uses logical subindexes of a composite index. The
database "skips" through a single index as if it were searching separate indexes. Skip
scanning is beneficial if there are few distinct values in the leading column of a
composite index and many distinct values in the nonleading key of the index.
The database may choose an index skip scan when the leading column of the
composite index is not specified in a query predicate. For example, assume that you
run the following query for a customer in the sh.customers table:
SELECT * FROM sh.customers WHERE cust_email = 'Abbey@company.com';
The customers table has a column cust_gender whose values are either M or F.
Assume that a composite index exists on the columns (cust_gender, cust_email).
Example3–1 shows a portion of the index entries.
Example 3–1 Composite Index Entries
F,Wolf@company.com,rowid
F,Wolsey@company.com,rowid
F,Wood@company.com,rowid
F,Woodman@company.com,rowid
F,Yang@company.com,rowid
F,Zimmerman@company.com,rowid
M,Abbassi@company.com,rowid
M,Abbey@company.com,rowid
The database can use a skip scan of this index even though cust_gender is not
specified in the WHERE clause.
In a skip scan, the number of logical subindexes is determined by the number of
distinct values in the leading column. In Example 3–1, the leading column has two
possible values. The database logically splits the index into one subindex with the key
F and a second subindex with the key M.
When searching for the record for the customer whose email is Abbey@company.com,
the database searches the subindex with the value F first and then searches the
subindex with the value M. Conceptually, the database processes the query as follows:
SELECT * FROM sh.customers WHERE cust_gender = 'F'
AND cust_email = 'Abbey@company.com'
UNION ALL
SELECT * FROM sh.customers WHERE cust_gender = 'M'
AND cust_email = 'Abbey@company.com'; |
|