Interview Question

What is index in SQL?

An index trades storage and write cost for potentially faster reads.

💡 Concept ✅ Quick Revision 🗃️ SQL

Answer

An index is a database structure that can speed access to table rows. • It stores indexed key values with references that help locate rows. • The optimizer chooses whether an index is useful for a query. • Indexes consume storage and add work to data changes.

💡 SQL Example

CREATE INDEX employees_department_idx ON employees (department_id);

Result

CREATE INDEX

⚡ Quick Revision

An index trades storage and write cost for potentially faster reads.