简体   繁体   中英

Performance effect of include column in index

We know that having index on a table, degrades the insert/update/delete (CUD) performance. I want to know if I use a field as included column, how much affect (CUD) performance.

what I mean is, comparing the performance degradation between following indexes:

CREATE UNIQUE NONCLUSTERED INDEX [Idx1] ON dbo.Table (Col1, Col2)

and

CREATE UNIQUE NONCLUSTERED INDEX [Idx1] ON dbo.Table (Col1, Col2) INCLUDE (Col3)

Notes:

  1. Col3 is a small field (like int/decimal/date)
  2. The table has about 100 million rows

If the INCLUDE column covers a query, that query is likely to be much faster. The down side is that other queries that use the index may be slightly slower.

Queries that are not covered by this index may perform more I/O when using this index. Adding an INCLUDE column will widen the size of the rows on the non-clustered index leaf pages. Wider rows means that fewer rows fit in a single leaf page. Queries that use this index to find many rows will have to load more pages.

The INCLUDE column will cause the index to take up more disk space. How much space depends on the data type of the column.

The index may take up more space in memory if many rows are scanned.

The best way to determine the impact of the INCLUDE column is to measure it. Run queries against the table before hand and measure I/O, disk space, and record the query plan. Run queries against it afterwards and do the same.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM