Diberdayakan oleh Blogger.

Is there any rule to decide what columns should be put in Included in non clustered index and in which order

Why use the INCLUDE clause when creating an index? Is there any rule to decide what columns should be put in Included in non clustered index and in which order.



I got that for the following query :

SELECT PrimaryInformation_Id, Company_Id, LastName
FROM Employee_PrimaryInformation
WHERE Company_Id = 5

I am suggested to make index like this:

CREATE NONCLUSTERED INDEX NC_EmpPrim
  ON Employee_PrimaryInformation(PrimaryInformation_Id, Company_Id)
  INCLUDE (LastName)

Yes, i know. what you think why can't we make index like this'

CREATE NONCLUSTERED INDEX NC_EmpPrim
      ON Employee_PrimaryInformation(PrimaryInformation_Id, Company_Id, LastName)

OR

CREATE NONCLUSTERED INDEX NC_EmpPrim
      ON Employee_PrimaryInformation(Company_Id, LastName)
INCLUDE (PrimaryInformation_Id)

For your example I've added a comment.'

CREATE INDEX <name> ON <table> (KeyColList) INCLUDE (NonKeyColList)
Where:

  • KeyColList = Key columns = used for row restriction and processing 
  • WHERE, JOIN, ORDER BY, GROUP BY etc
  • NonKeyColList = Non-key columns = used in SELECT and aggregation (e.g. SUM(col)) after selection/restriction
Thank you for reading the article about Is there any rule to decide what columns should be put in Included in non clustered index and in which order on the blog NEW TECH If you want to disseminate this article on please list the link as the source, and if this article was helpful please bookmark this page in your web browser by pressing Ctrl + D on your keyboard keys.

New articles :

  • Disable T5120 RAID - Cause failure in booting/installing from HD
  • How To Reset The ALOM Password On A Sun Fire T2000
  • Broadband Error Codes
  • Error 651: How to Fix it in Windows 7/8
  • How to Set up a new PPPoE connection on your Windows 7
  • Installing Net-SNMP on Solaris OS
  • How to Upgrade to Perl 5.12.5 on Linux Machine
  • how to get process id attached with particular port in solaris
  • Year 2038 problem
  • Windows exchange Server 2007 installation Steps
  • Related articles :