Back to all questions

What Are Clustered and Non-Clustered Indexes?

DatabasesSenior
Seen on interview:0 users

This is a classic database theory question - and in my opinion, it comes with a twist. The twist is that you’ve already worked with clustered/non-clustered indexes and you definitely know them. You just didn’t know they were called that 😁

First, answer the question:

Clustered

A clustered index defines the order in which data is physically stored on disk. Because of that, a table can have only one clustered index - most often, it’s the primary key.

Non-Clustered

A non-clustered index does not change the data on disk. Instead, it creates a separate structure to store index data (B-tree, hash, etc.). Put simply, these are the regular indexes we create to optimize database performance.

After answering the question, you can steer the conversation in the direction you want. A great next step is to start talking about different types of non-clustered indexes.

Seen on interview?

Comments (0)

Sign in to leave a comment

No comments yet. Be the first!