Ques:- Explain real time situation where you would use clustered and Non-clustered Indexes?
Asked In :-
BillDesk, Systematix Infotech, SDL, District Cooperative Central Bank DCCB, RORO, Intelizign, Deep Compute, Interview Mocha, Konnect Insights, Paxcom,
Right Answer:
In a real-time situation, you would use a clustered index for a primary key column in a large table where you frequently query ranges of data, such as retrieving all orders within a specific date range. This is because a clustered index sorts and stores the data rows in the table based on the indexed column, improving the performance of range queries.
On the other hand, you would use a non-clustered index for columns that are frequently searched but not part of the primary key, such as a customer name or email address. This allows for faster lookups without affecting the physical order of the data in the table.
In a real-time situation, you would use a clustered index for a primary key column in a large table where you frequently query ranges of data, such as retrieving all orders within a specific date range. This is because a clustered index sorts and stores the data rows in the table based on the indexed column, improving the performance of range queries.
On the other hand, you would use a non-clustered index for columns that are frequently searched but not part of the primary key, such as a customer name or email address. This allows for faster lookups without affecting the physical order of the data in the table.