# Clustered Index vs Non-clustered index

In a clustered index, the physical order of the rows in the table matches the order of the index. When you query based on the clustered index key, the database can quickly locate the rows because they are stored in sorted order.&#x20;

In a non-clustered index, the physical order of the rows in the table does not match the order of the index. Non-clustered indexes contain pointers to the actual rows in the table.

When a query is issued against a column on which the index is created, the database will first go to the index and look for the address of the corresponding row in the table. It will then go to that row address and fetch other column values. It is due to this additional step that non-clustered indexes are slower than clustered indexes.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://huy312100.gitbook.io/software-development/dbms/fundamental/index/clustered-index-vs-non-clustered-index.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
