SQL Server:是否值得将BLOB / CLOB列放在表的“结尾”附近?

时间:2022-06-13 03:18:08

Is is an urban legend or having BLOB/CLOB columns last in a list of columns in a table really benefits performance and other aspects?

是一个城市传说还是BLOB / CLOB列最后列在一个表的列中真的有利于性能和其他方面?

To "visualise". Is there any difference performance-wise (and other- wise) between these two table layouts:

要“想象”。这两个表布局之间在性能方面(以及其他方面)是否存在任何差异:

A                            B
---------------------        ---------------------
ID      int                  ID      int
Name    nvarchar(200)        Content nvarchar(max)
Content nvarchar(max)        Name    nvarchar(200)

1 个解决方案

#1


2  

Yes, it's an urban legend

是的,这是一个都市传奇

On-disk layout is completely independent of the ordering of columns in the CREATE table. See this for more Performance / Space implications when ordering SQL Server columns?

磁盘布局完全独立于CREATE表中列的顺序。订购SQL Server列时,请参阅此内容以获得更多性能/空间影响?

Note: whether a varchar column is at the "start" or the "end", SQL Server still reads it the same via an offset from the NULL bitmap. The MAX column may be in the record or in another page if too long. SO still doesn't matter

注意:无论varchar列是在“start”还是“end”,SQL Server仍然通过NULL位图的偏移量读取它。如果太长,MAX列可能在记录中或在另一页中。所以仍然无所谓

There was an issue years ago (pre-dot net) with some SQL Server client drivers that preferred large text parameters at the end. Ancient myths.

几年前(pre-dot net)出现了一个问题,其中一些SQL Server客户端驱动程序最后都喜欢大文本参数。古代神话。

#1


2  

Yes, it's an urban legend

是的,这是一个都市传奇

On-disk layout is completely independent of the ordering of columns in the CREATE table. See this for more Performance / Space implications when ordering SQL Server columns?

磁盘布局完全独立于CREATE表中列的顺序。订购SQL Server列时,请参阅此内容以获得更多性能/空间影响?

Note: whether a varchar column is at the "start" or the "end", SQL Server still reads it the same via an offset from the NULL bitmap. The MAX column may be in the record or in another page if too long. SO still doesn't matter

注意:无论varchar列是在“start”还是“end”,SQL Server仍然通过NULL位图的偏移量读取它。如果太长,MAX列可能在记录中或在另一页中。所以仍然无所谓

There was an issue years ago (pre-dot net) with some SQL Server client drivers that preferred large text parameters at the end. Ancient myths.

几年前(pre-dot net)出现了一个问题,其中一些SQL Server客户端驱动程序最后都喜欢大文本参数。古代神话。