Performance of non-clustered indexes on different column types
Is a non-clustered index on an 开发者_运维技巧int
column considered more performant than one on a decimal
or datetime
column?
In some ways: yes.
An INT
is only 4 bytes - so more INT
s will fit on a single 8K page in SQL Server.
DATETIME
uses 8 bytes - so fewer DATETIME
values are store on a single page, or for the same number of DATETIME
s, you need more pages, hence you get more disk I/O and thus less performance.
How much of a difference there is, is up to more detailed measurement, however - for anything under millions of rows, the difference most likely will be negligable. If your queries do benefit from an index on that DATETIME
column - I wouldn't hesitate adding it (again: unless you're dealing with multi-million row tables... then you might need more detailed investigations)
精彩评论