When creating an index for a specific query is it good practice to index all columns that are in the where clause and then have any columns selected in the “included columns” section? Should I leave bit columns out of the index?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Bit of a classic “it depends”. If you include them, then you are creating a covering index, which will be far more efficient but equally you will incur a penalty on row insertion, deletions and some updates.
You also pay a price on the disk space, so if you are going to include very wide columns on a large table, you are balancing the increase in storage overhead vs the performance gain.
All things being equal, a covering index is normally a good thing, but there are caveats such as the space and overhead on other operations to be mindful of.