Tag Archives: SQL Indexes

Interview question – Is Clustered index on column with duplicate values possible?

By | August 13, 2015

Through this article, we are going to discuss three important interview questions of SQL which are given below:-  1) Can we create clustered index on a column containing duplicate values?  2) Can we create a Primary Key on a table on which a clustered index is already defined? 3) If a clustered index is already defined on a… Read More »

SQL Script to find the missing indexes

By | January 25, 2015

Script to find the missing indexes Performance tuning in SQL is important exercise and index creation is an important part of it. Below script will help in finding the missing indexes. Once you create these indexes, it will help in improving the Performance.SELECT db_name(d.database_id) dbname , object_name(d.object_id) tablename , d.equality_columns , d.inequality_columns , d.included_columns ,’CREATE INDEX [missing_index_’ +… Read More »

Script to find the Fragmentation of indexes

By | January 4, 2015

Below is the script to find the fragmentation of the indexes created on a database. SELECT OBJECT_NAME(OBJECT_ID), index_id,index_type_desc,index_level, avg_fragmentation_in_percent,avg_page_space_used_in_percent,page_count FROM sys.dm_db_index_physical_stats (DB_ID( N’Database name’) , NULL, NULL, NULL , ‘SAMPLED’) ORDER BY avg_fragmentation_in_percent DESC avg_fragmentation_in_percent represents  logical fragmentation. If this value is higher than 5% and less than 30%, then we should use  ALTER INDEXREORGANIZE If this value… Read More »

Rebuild And Reorganization of Indexes

By | December 31, 2012

Rebuild and  Reorganization of Indexes:- SQL Server has the ability of maintaining the indexes whenever we makes changes (update, Insert, Delete) in the tables. Over a period of time, the may causes the fragmentation on the table in which  the logical ordering based on the key value pairs does not match with the physical ordering inside the data… Read More »

Fragmentation in SQL Server

By | December 31, 2012

Fragmentation:- Fragmentation can be defined as condition where data is stored in a non continuous manner. In can be defined into two types 1. Internal Fragmentation 2. External Fragmentation Internal Fragmentation:- In this fragmentation, there exists a space between the different records within a page. This is caused due to the Insert, delete or Update process… Read More »

Difference between Clustered Index and Non clustered Index

By | January 3, 2010

Indexes-Indexing  is way to sort and search records in the table. It will improve the speed of locating and retrieval of records from the table.It can be compared with the index which we use in the book to search a particular record. In Sql Server there are two types of Index 1) Clustered Index 2)… Read More »