Covering Index vs Include Index

  • Iā€™m looking intocreating indexes and I want to know which types of indexes are better and inwhich situations to use them INCLUDE and COVERING?

     

     

    Thank you inadvance!

  • tt-615680 - Friday, February 23, 2018 4:03 AM

    I’m looking intocreating indexes and I want to know which types of indexes are better and inwhich situations to use them INCLUDE and COVERING?

     

     

    Thank you inadvance!

    This is entirely too vague for anything resembling a cohesive response. What you are asking is a very big topic. I would suggest you start reading up on indexes in depth so you better understand how they work. Once you have that knowledge you will know what types of indexes would be appropriate in the situations you are asking about. Lucky for you there is a spectacular series of articles right here on SSC that discusses indexes from the basics to a pretty deep level. http://www.sqlservercentral.com/stairway/72399/

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 ā€“ Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • tt-615680 - Friday, February 23, 2018 4:03 AM

    I’m looking intocreating indexes and I want to know which types of indexes are better and inwhich situations to use them INCLUDE and COVERING?

     

     

    Thank you inadvance!

    Also, the INCLUDE clause in CREATE INDEX is one way of creating a covering index.  The other is to define all the columns as part of the index but then you are limited to either 16 columns or 900 bytes, which ever happens first.  As Sean said above, you really need to learn more about indexes.

  • Sean is correct, you have asked a vague question.

    A covering index includes all the information needed for a query. This means the columns in the SELECT list, as well as join/where/on/having clauses exist in the index. Therefore the query doesn't need to access the clustered index or heap for data. Any index can be covering, depending on the query.

    An INCLUDE adds columns to the index that are stored with the index, but aren't used as part of the searching. For example, if I had ProductID and Product Name in the index, I can use those in WHERE clauses or other filters. However, if UnitPrice is INCLUDEd, this is only useful if the query uses the column in the SELECT list. If we searched on WHERE UnitPrice > 10, this index isn't used. Think of this as other information added to the index that is returned to the user, but not used to run the query filters.

  • tt-615680 - Friday, February 23, 2018 4:03 AM

    I’m looking intocreating indexes and I want to know which types of indexes are better and inwhich situations to use them INCLUDE and COVERING?

     

     

    Thank you inadvance!

    Should need more information to comment.

    COVERING INDEX - An index that contains all information required to resolve the query is known as a “Covering Indexâ€; it completely covers the query

    INCLUDE COLUMNS - You will normally use the INCLUDE to add one or more columns to the leaf level of a non-clustered index, so that, you can "cover" your queries.

    So you can understand the differences here.

    Please go thru the similar topic posted here,

    https://www.sqlservercentral.com/Forums/Topic509318-360-1.aspx

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply