Explain why creating more than one clustered index in a table is considered undesirable practice.
sobes.tech AI
Answer from AI
In relational databases, a clustered index determines the physical order of storing rows in a table. Since rows can only be ordered in one way, creating more than one clustered index is either impossible or undesirable.
Attempting to create multiple clustered indexes will lead to conflicts because the physical data order cannot simultaneously match different indexes. Usually, a table can have only one clustered index, which optimizes access based on a specific column or set of columns.
Therefore, creating more than one clustered index is considered bad practice because:
- It is technically impossible in most DBMSs.
- Attempting to emulate multiple clustered indexes leads to performance degradation.
- It is better to use non-clustered indexes for other queries.
Example: In a table with customer data, you can create a clustered index on the "Customer ID" field so that data is stored in order of ID. Trying to create another clustered index on the registration date is impossible because the physical order is already set.