What is Index? Types of Index in SQL Server
What is Index? Types of Index in SQL Server
Student
The Anubhav portal was launched in March 2015 at the behest of the Hon'ble Prime Minister for retiring government officials to leave a record of their experiences while in Govt service .
An Index in SQL Server is a database object that improves the speed of data retrieval from a table—just like an index in a book helps you quickly find a topic without scanning every page.
In Microsoft SQL Server:
Why Use Indexes?
SELECTqueriesJOIN,ORDER BY,GROUP BYperformanceBut:
INSERT,UPDATE,DELETETypes of Indexes in SQL Server
1. Clustered Index
Example:
Use Case:
2. Non-Clustered Index
Example:
Use Case:
WHERE Name = 'John')3. Unique Index
Example:
4. Composite Index (Multi-Column Index)
Index on multiple columns
Example:
Use Case:
WHEREclause5. Filtered Index
Example:
6. Full-Text Index
7. Columnstore Index
Use Case:
8. XML Index
Used for querying XML data efficiently
9. Spatial Index
Used for geographic or spatial data
Clustered vs Non-Clustered (Quick Comparison)
When to Use Indexes
WHERE,JOIN,ORDER BYWhen NOT to Use
Simple Analogy