Câu hỏi phỏng vấn Databases
Câu hỏi

What are the difference between Clustered and a Non-clustered index?

Câu trả lời

To answer the interview question "What are the differences between a clustered and a non-clustered index?" comprehensively, you can highlight the following points:

Clustered Index

  1. Physical Order: A clustered index determines the physical order of data storage in a table. The data rows are stored in sorted order based on the key values of the clustered index[1][2][5].
  2. Single Index: Each table can have only one clustered index because there can be only one physical order of data[1][2][3].
  3. Performance: Clustered indexes are generally faster for data retrieval because the data is stored in the same order as the index. However, they can slow down insert, update, and delete operations due to the need to maintain the physical order[1][2][3].
  4. Storage: Clustered indexes do not require additional storage space for the index itself, as the data is stored in the same structure[1][3].
  5. Use Cases: Ideal for range queries and scenarios where data retrieval speed is critical, especially when the data is relatively static[1][3][6].

Non-Clustered Index

  1. Logical Order: A non-clustered index does not affect the physical order of data in the table. Instead, it creates a separate structure that points to the data rows[1][2][5].
  2. Multiple Indexes: A table can have multiple non-clustered indexes, allowing for various ways to access the data efficiently[1][2][3].
  3. Performance: Non-clustered indexes are generally slower for data retrieval compared to clustered indexes because they involve an additional lookup step to fetch the actual data. However, they are faster for insert, update, and delete operations as they do not require maintaining the physical order of data[1][2][3].
  4. Storage: Non-clustered indexes req...
middle

middle

Gợi ý câu hỏi phỏng vấn

expert

What is Optimistic Locking and Pessimistic Locking?

expert

Name some disadvantages of a Hash index

expert

What are some other types of Indexes (vs B-Trees)?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào