SQL INTERVIEW PREPARATION PART-15

Data Analytics
Mr. Plan ₿ Publication
1 min readJun 18, 2024

What are indexes in SQL, and why are they used?

Indexes are database objects created on tables and views that improve the speed of data retrieval operations. They work by providing a fast way to look up rows based on the values of one or more columns.

Types of indexes:
- Clustered Index: Alters the physical order of the table and is limited to one per table. The table data is sorted according to the clustered index.
- Non-Clustered Index: Does not alter the physical order of the table. It creates a separate object within the table that points back to the original table rows.

Example:
CREATE INDEX idx_employee_name ON employees(name);
In this example, an index is created on the name column of the employees table.

Tip: Explain that while indexes can significantly speed up data retrieval, they can also slow down data modification operations (INSERT, UPDATE, DELETE) because the indexes need to be maintained. Emphasize the importance of choosing the right columns for indexing based on query patterns and database performance analysis.

You can refer these SQL Interview Resources to learn more

Like this post if you want me to continue this SQL series 👍♥️

Share with credits: https://t.me/sqlspecialist

Hope it helps :)

--

--

Data Analytics
Mr. Plan ₿ Publication

Data Science, SQL, Excel, Python, Power BI, Tableau & Machine Learning Best Resources: heylink.me/DataAnalytics