In SQL Server, you can include nonkey columns in a nonclustered index to avoid the limitation of a maximum of 16 key columns. For more information, see Create Indexes with Included Columns. The maximum number of bytes in an index key is 900.
- Include nonkey columns in a nonclustered index to avoid exceeding the current index size limitations of a maximum of 32 key columns and a maximum index key size of 1,700 bytes (16 key columns and 900 bytes prior to SQL Server 2016 (13.x)). The Database Engine does not consider nonkey columns when calculating the number of index key columns or index key size.
Anytime you're in a query, narrowing down the number of results to deal with before the next step means better performance.
Since the index is also stored this way, there's no backtracking across the index to find the first column when you're querying on it.
In short: No, it's not for show, there are real performance benefits.
CREATE NONCLUSTERED INDEX ix_orderid
ON dbo.Sales(OrderID)
INCLUDE (OrderDate);
No comments:
Post a Comment