Create & Test for NONCLUSTERED INDEX and CLUSTERED INDEX
2012-09-24 15:49
781 查看
1. Create and delete clustered index
2. Refer to http://www.blogjava.net/jiabao/archive/2008/04/08/191595.html
2.1 【Table Scan】 打开执行计划,如果没有索引所有的查询为 “Table Scan”
【非聚簇索引 Unique Nonclustered Index】
2.2 【Index Scan】 当查询中只选择有索引的字段时,SQL Server就使用“Index Scan”方法。
2.3 【Index Seek】 WHERE后面使用带索引的字段PRID来进行过滤。
小结: “Index Seek”利用“WHERE”来过滤获取的数据, 不需要对表和索引页进行扫描;而“Table Scan”和“Index Scan”需要。
【[b]聚簇索引 Unique Clustered Index】[/b]
2.4 【Clustered Index Scan/Seek 】 当在WHERE后用到PRCode字段的时候,“Clustered Index Seek”被用到,否则都是Clustered Index Scan
小结: “Clustered Index Seek”不需要扫描整个聚集索引页。 和“Index Scan”相比,对于检索选择的字段包含那些没有索引的字段时,“Clustered Index Seek”不会有“Bookmark Lookup”方法出现。
Drop Index PerformanceIssue.UNC_PRID CREATE UNIQUE NONCLUSTERED INDEX UNC_PRID ON PerformanceIssue (PRID) CREATE UNIQUE CLUSTERED INDEX UC_PRCode ON PerformanceIssue(PRCode)
2. Refer to http://www.blogjava.net/jiabao/archive/2008/04/08/191595.html
2.1 【Table Scan】 打开执行计划,如果没有索引所有的查询为 “Table Scan”
【非聚簇索引 Unique Nonclustered Index】
2.2 【Index Scan】 当查询中只选择有索引的字段时,SQL Server就使用“Index Scan”方法。
Select PRID From PerformanceIssue
2.3 【Index Seek】 WHERE后面使用带索引的字段PRID来进行过滤。
Select PRID, PRCode, PRDesc From PerformanceIssue Where PRID = 'D386C151-5F74-4C2A-B527-86FEF9712955'
小结: “Index Seek”利用“WHERE”来过滤获取的数据, 不需要对表和索引页进行扫描;而“Table Scan”和“Index Scan”需要。
【[b]聚簇索引 Unique Clustered Index】[/b]
2.4 【Clustered Index Scan/Seek 】 当在WHERE后用到PRCode字段的时候,“Clustered Index Seek”被用到,否则都是Clustered Index Scan
Select PRID, PRCode, PRDesc From PerformanceIssue Where PRCode = 8
小结: “Clustered Index Seek”不需要扫描整个聚集索引页。 和“Index Scan”相比,对于检索选择的字段包含那些没有索引的字段时,“Clustered Index Seek”不会有“Bookmark Lookup”方法出现。
相关文章推荐
- An Introduction to Clustered and Non-Clustered Index Data Structures
- Clustered Index and Non-Clustered Index
- Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again.
- CREATE A NON-EXPIRING TEST CERTIFICATE (PFX) FOR CLICKONCE APPLICATIONS
- Clustered Index & Non Clustered Index
- spring 'arroudAspect' for bean class [com.dw.test.ArroudAspect] conflicts with existing, non-compatible bean definition of same name and class [com.dw.aspect.ArroudAspect]
- Clustered Index & Non Clustered Index(聚簇索引和非聚簇索引)
- Clustered Index and NonClustered Index (Correction)
- [MAVEN] - Add "provided" and "test" scopes for dependency
- Clustered Index & Non Clustered Index
- Clustered Index & Non Clustered Index
- Clustered Index and Non-Clustered Index
- CREATE UNIQUE INDEX 终止,因为发现了索引 ID 1 的重复键。最重要的主键为 'type 6c, len 9'。
- What is the HINSTANCE passed to CreateWindow and RegisterClass used for?
- AT&T ASSEMBLY FOR LINUX AND MAC (SYS_FORK)
- SQL2,CREATE TABLE AND CREATE INDEX
- Undefined symbols for architecture i386: "_SCNetworkReachabilityCreateWithAddress"
- How to Read and Understand a Scientific Paper: A Step-by-Step Guide for Non-Scientists
- How to enable time stamps for logs in 'dmesg' on Gaia and SecurePlatform
- How to create and use SDCard image for Android emulator