Sql Server

SQL | Index with included columns

SQL | Index with included columns

SQL | Index with included columns

An index created with included columns is a non-clustered index that also includes non-key columns in the leaf nodes of the index, similar to a clustered index.

Benefits of included columns
1. Gives you the ability to include columns types that are not allowed as index keys in your index.
2. when all the columns in your query are either an index key or included column, the query no longer has to do an extra lookup in order to get all the data needed to satisfy the query which results in fewer disk operations. This is similar to the covering index

Create Index with Included Columns

Create table Student
    Roll_No int primary key,
    Name varchar(50),
    Gender varchar(30),
    Mob_No bigint

   ON Student (Name ASC) INCLUDE (Gender);

Using the same query as above this should also be able to execute without requiring any extra lookups.

SELECT Roll_No, Name FROM Student WHERE Gender = 'M';

Related Post

About Us

Community of IT Professionals

A Complete IT knowledgebase for any kind of Software Language, Development, Programming, Coding, Designing, Networking, Hardware and Digital Marketing.