Efficiency of checking for null varbinary(max) column?

删除回忆录丶 提交于 2019-12-22 11:05:19

问题


Using SQL Server 2008.

Example table :

CREATE table dbo.blobtest
(id int primary key not null,
name nvarchar(200) not null, 
data varbinary(max) null)

Example query :

select id, name, 
cast((case when data is null then 0 else 1 end) as bit) as DataExists 
from dbo.blobtest 

Now, the query needs to return a "DataExists" column, that returns 0 if the blob is null, else 1.

This all works fine, but I'm wondering how efficient it is. i.e. does SQL server need to read in the whole blob to its memory, or is there some optimization so that it just does enough reads to figure out if the blob is null or not ?

(FWIW, the sp_tableoption "large value types out of row" option is set to OFF for this example).


回答1:


It uses the NULL bitmap. So no.




回答2:


Actually it can not read the blob because there is no blob to start with ;)



来源:https://stackoverflow.com/questions/2816096/efficiency-of-checking-for-null-varbinarymax-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!