An index is one of the important role to improve the query performance of SQL Server database .It makes the querying process fast by providing easy access to rows in data tables, similar to how a book’s index will quickly locate information inside that book.We can also create indexes in SQL Server using both GUI and t-SQL method. Once we create an index using t-SQL, we specify the index name, key columns, included columns, filter to create it. We do not consider other index options. While on the other hand, if you use the SSMS GUI method, it gives many options to you. You might get overwhelmed with all SSMS index options.

There are two types of indexes mainly used in SQL Server:

1. Clustered Index

Clustered indexes use key values for sorting data rows in tables or view. They are included in the index definition. It always stores the index value in a B-tree structure where the actual data is stored in the leaf node.
Since the data rows are stored in one direction, each table can only have a single clustered index. A table stored the rows in sorted order only when the table has a clustered index. We can refer to a clustered table as one that has a clustered index. If a table doesn’t have a clustered index, its rows are stored in a heap, which is an unordered structure.
The main benefit of a clustered index is the data is physically sorted by the clustered key value in your storage system, and searching for a range of values will be fast. Its main disadvantage is the Last Page Insert Latch Contention that inserts data only at the end of the clustered index.

let see how to create Clustered index by script :


Now we will see how to create by GUI



It gives you the following script with all default configurations:



2. Nonclustered Index

The Non-Clustered indexes contain a copy of the indexed columns along with a pointer that refers to the location of the actual data in the table. It is similar to an index in a textbook that lists the topics and their corresponding page numbers, allowing readers to quickly find the information they need without having to read through the entire book.
The non-clustered indexes are a type of index used in databases to speed up the execution time of database queries.These indexes require less storage space than clustered indexes because they do not store the actual data rows.We can create multiple non-clustered indexes on a single table.


It gives you the following script with all default configurations:

  • SQL indexes are essential tools that significantly enhance the performance and effectiveness of querying databases. They act as unnoticeable attendants, allowing the database operation system to fleetly detect and recoup data from tables, thereby speeding up quests and queries. While druggies may not directly interact with indexes, their impact on the overall database performance is substantial.
  • In substance, an indexes in SQL functions much like an indexes in a book or a roster. Just as a book indexes helps compendiums snappily find specific information, a SQL indexes enables the database machine to fleetly detect and pierce applicable data, saving precious time and coffers. By creating an indexes on one or further columns of a table, the database can organize and sort the data in a way that facilitates quicker data reclamation. This association is akin to sorting data alphabetically or numerically, making it easier to find what bone is looking for.
  • The process of creating an indexes involves using the CREATE indexes statement in SQL. This statement allows druggies to specify the name of the indexes, the table on which the indexes should be created, and the columns to be included in the indexes. Once the indexes is created, the database system maintains it automatically as data is fitted , streamlined, or deleted from the table.
  • Although indexes greatly enhance query performance, they do come with certain trade- offs. One notable trade- off is the impact on data revision operations, similar as updates and inserts. When data in a table is modified, the corresponding indexes must also be streamlined to insure their delicacy and thickness. Accordingly, this fresh outflow can affect in slightly slower update and fit operations compared to tables without indexes.
  • In conclusion, SQL indexes play a vital part in enhancing the speed and effectiveness of data reclamation operations in databases. They operate as hidden sidekicks, working behind the scenes to insure that queries are executed fleetly and effectively. By organizing data in a structured manner, indexes enable the database operation system to detect information fleetly, analogous to how a book’s indexes assists compendiums in chancing particular sections. still, it’s pivotal to be aware of the trade- offs, particularly the implicit impact on data revision operations. picky and well- considered use of indexes is crucial to employing their full eventuality and icing optimal database performance. Eventually, the benefits of indexes in expediting quests and queries make them necessary tools in the realm of database here to know more about Indexes 

How to check indexes by T-sql

Leave a Reply

Your email address will not be published. Required fields are marked *