Answer
Indexes in SQL are special database structures that speed up data retrieval by allowing quick access to records instead of scanning the entire table. They act like a lookup system and play an important role in improving query performance and database efficiency.
- It speed up queries (SELECT, JOIN, WHERE, ORDER BY).
- Reduce disk I/O and improve efficiency in large tables.
- Ensure data integrity with unique indexes.
Creating an Index
Single Column Indexes
A single-column index is created on just one column. It’s the most basic type of index and helps speed up queries when you frequently search, filter or sort by that column.
Syntax:
Example: SQL database and table, on which we implement the Indexes.

Query:
Explanation: This creates an index named idx_product_id on the product_id column.
Multi Column Indexes
A multi-column index is created on two or more columns. It improves performance when queries filter or join based on multiple columns together.
Syntax:
Query:
Explanation: This index allows database to quickly filter or join data based on both product_id and quantity columns with a confirming message.
Advantages of Indexes
✅ Faster SELECT queries
✅ Efficient sorting and filtering
✅ Improves JOIN performance
✅ Reduces full table scans
Disadvantages of Indexes
❌ Slower INSERT, UPDATE, DELETE
❌ Extra storage required
❌ Index maintenance overhead
❌ Over-indexing hurts performance