Does SQL Server create a non-clustered index across all columns of a table by default

Will sql server create any non-clustered index by default? Should we put all FKs in a non-clustered index? What is the trade off here

+2
source share
1 answer

No, SQL Server does not automatically create non-clustered indexes.
A clustered index is created automatically based on the primary key, unless your CREATE TABLE statement says otherwise.

Yes, I would recommend indexing foreign key columns because they are most likely for JOIN'd / search versus using IN , EXISTS , etc. However, keep in mind that a low power gain index value (e.g. gender) will be relatively useless because there is not enough difference in the values.

The tradeoff with all indexes is that they can speed up data retrieval but slow down data insertion / update / deletion. It also requires maintenance that needs to be performed, as they may be fragmented (for example, hard drives), but may also not be used over time. Indexes also occupy disk space.

+8
source

Source: https://habr.com/ru/post/945824/


All Articles