开发者

Efficiency of checking for null varbinary(max) column?

开发者 https://www.devze.com 2022-12-29 19:56 出处:网络
Using SQL Server 2008. Example table : CREATE table dbo.blobtest (id int primary key not null, name nvarchar(200) not null,

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 whe开发者_JAVA百科n 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).


It uses the NULL bitmap. So no.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消