[英]Do SQL Server included columns takes double space?
我的問題是例如我有以下專欄
Cl1 int - primary key
Cl2 int
Cl3 nvarchar(200)
Cl4 nvarchar(max)
現在假設我在Cl2
上創建了一個非聚集索引,但是當我查詢Cl2
我總是也檢索Cl3
和Cl4
。
將Cl3
包含在索引中是合乎邏輯的,因為它將使檢索操作更快,但是Cl4
是nvarchar(max)
並且可能很大:此列包含已爬網的頁面源
所以我的問題是:在非聚集索引中是否包含Cl4
是合乎邏輯的
包括它會使Cl4
精確地存儲在硬盤上2次嗎?
非常感謝您的回答
SQL Server 2014
從針對SQL Server 2014的聯機叢書中獲得:
Up to 16 columns can be combined into a single composite index key. All the columns in a composite index key must be in the same table or view. The maximum allowable size of the combined index values is 900 bytes.
Columns that are of the large object (LOB) data types ntext, text, varchar(max), nvarchar(max), varbinary(max), xml, or image cannot be specified as key columns for an index.
如您所料,包括C14可能會以磁盤空間為代價,對某些性能產生積極影響。 我想您也了解,受此影響的不僅是磁盤空間,還包括插入,更新和刪除。 更改是否值得取決於您的系統。 我鼓勵您對這兩個選項進行真實的性能分析。 然后根據結果做出決定。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.