1. Why we need the index 'include' feature?

For SQLServer , the length of all the index key have a limit length as 900 byte.

when you create a index whose keys' total length may exceced 900 byte , such as below

CREATE TABLE GPCUSTEXT(
CUSTNO nvarchar(20),
FIELD_VALUE nvarchar(2000) ,
CREATED_ON datetime ,
CREATED_BY int ,
MODIFIED_ON datetime ,
MODIFIED_BY int ,
EXTCUST_ID int NOT NULL,
METAFIELD_ID int,
CONSTRAINT PK_GPCUSTEXT PRIMARY KEY CLUSTERED (EXTCUST_ID)
)

go

create index GPCUSTEXT_CUSTNO_METAFIELD_ID on gpcomp1.GPCUSTEXT(CUSTNO,METAFIELD_ID,FIELD_VALUE)

you will got as warning saying the data length may exceed the 900 byte
at that situation sqlserver cannot put all key data into the index tree.

or you want to have a LOB column in the index , such as below

CREATE TABLE GPPROB(
PROBLEM_ID int NOT NULL,
CUSTNO nvarchar(20) NULL,
SALESID nvarchar(45) NULL,
PCODE nvarchar(10) NULL,
STATUS nvarchar(100) NULL,
PTEXT nvarchar(max) NULL,
CONSTRAINT PK_GPPROB PRIMARY KEY CLUSTERED (PROBLEM_ID)
)

go

create index GPPROB_CUSTNO_PTEXT on GPPROB(CUSTNO,PTEXT)

you will got an error saying the PTEXT is invalid for index as it is a LOB.

So SQLServer introduced the 'include' feature to go around above
situation.

Also if we updated the 'include' column, the index no need to
re-order due to the 'include' has nothing with the index tree leaf
order.

Vice versa, the SQLServer will not consider the 'include' column
when judge which index need to use.

then execute a query sql as below

select custno,ptext from gpcomp1.GPPROB

Due to the 'include' column , the index
'GPPROB_CUSTNO_PTEXT' have all data needed for the query sql,

so then
sqlserver will only scan the index 'GPPROB_CUSTNO_PTEXT' to get all
data.  It will not access the table.

We only have to consider the 'include' column when the key length is exceed 900 byte or want to include a LOB column to improve the performance.

The include feature of SQL Server Index的更多相关文章

  1. [SQL Server]Index/deadlock

    http://www.cnblogs.com/tintown/archive/2005/04/24/144272.html http://coolshell.cn/ http://blogs.msdn ...

  2. SQL Server Index详解

    最近在进行数据库调优,对索引的使用和其内部的运转一知半解.在园子里看到一篇相关文章非常好.留下印记以便日常查找. http://www.cnblogs.com/xwdreamer/archive/20 ...

  3. 转:Sql Server中的表访问方式Table Scan, Index Scan, Index Seek

    0.参考文献 Table Scan, Index Scan, Index Seek SQL SERVER – Index Seek vs. Index Scan – Diffefence and Us ...

  4. Microsoft SQL Server Trace Flags

    Complete list of Microsoft SQL Server trace flags (585 trace flags) REMEMBER: Be extremely careful w ...

  5. Microsoft SQL Server Version List [sqlserver 7.0-------sql server 2016]

    http://sqlserverbuilds.blogspot.jp/   What version of SQL Server do I have? This unofficial build ch ...

  6. P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1

    P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1       May ...

  7. Sql Server查询性能优化之不可小觑的书签查找

    小小程序猿SQL Server认知的成长 1.没毕业或工作没多久,只知道有数据库.SQL这么个东东,浑然分不清SQL和Sql Server Oracle.MySql的关系,通常认为SQL就是SQL S ...

  8. SQL Server: Top 10 Secrets of a SQL Server Expert

    转载自:http://technet.microsoft.com/en-us/magazine/gg299551.aspx Many companies have downsized their IT ...

  9. SQL Server 2008 R2 SP3 and SQL Server 2008 SP4 are now available!

    时间 2014-10-02 00:00:00 SQL Server Team Blog   原文  http://blogs.technet.com/b/dataplatforminsider/arc ...

随机推荐

  1. 移动端JD首页H5页面

    1:理解View :<meta name="viewport" content="width=device-width,initial-scale=1.0" ...

  2. OpenCV 2.4.10 Linux Qt Conifguration

    Download CMake 2.8.12 Extract the file, and run "./bootstrap", then "make", then ...

  3. [百科] - iLBC

    iLBC是一种专为包交换网络通信设计的编解码,优于目前流行的G.729.G.723.1,对丢包进行了特有处理,即使在丢包率相当高的网络环境下,仍可获得非常清晰的语音效果. 30ms ptime的iLB ...

  4. 针对binlog MIXED格式对表的增删改统计分析

    通常情况下DB都是有非常完整的监控的,那么如果监控不完善,那么在某段时间内又发生了性能问题,那么我们也可以分析binlog来尝试找到问题.下面就贴出命令,其实就是常用的命令组合. mysqlbinlo ...

  5. [转自51CTO]ITIL与ISO20000的关系

    ITIL它不是一个服务管理标准,而更应该说是一种结构化的方法或流程框架.基于这种方法和框架,已经有越来越多的IT服务管理标准被开发出来了.在这些基于ITIL的IT服务管理标准中,最突出的要属英国标准B ...

  6. Metasploit 笔记

    目录一.名词解释···································································· 3二.msf基础··············· ...

  7. [故障处理]联想笔记本故障0x0000007B

    同事笔记本故障,莫名其妙的快捷方式就找不到了.开始程序中的内容也无法正常查看. 解决步骤: 1.怀疑用户配置的问题,新建一个用户,没有解决. 2.使用自带的一键恢复ThinkVantage,恢复后,重 ...

  8. VNC与Windows之间的复制粘贴

    假设目标主机是Linux,终端主机是Windows(就是在Windows上使用VNC登陆Linux): 在Linux中执行: vncconfig -nowin& 在Linux选中文字后,无需其 ...

  9. Python实用工具包Scrapy安装教程

       对于想用每个想用Python开发网络爬虫的开发者来说,Scrapy无疑是一个极好的开源工具.今天安装之后觉得Scrapy的安装确实不易啊.所以在此博文一篇,往后来着少走弯路. 废话不多说了,如果 ...

  10. windows系统中ubuntu虚拟机安装及web项目到服务上(三)

    项目在ubuntu虚拟机下的部署 一:将war从本地通过Xftp 4 传到虚拟机tomcat目录下的webapps目录下 2:修改tomcat下的server.xml  <Host name=& ...