检查空 varbinary(max) 列的效率? [英] Efficiency of checking for null varbinary(max) column?

查看:32
本文介绍了检查空 varbinary(max) 列的效率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 SQL Server 2008.

Using SQL Server 2008.

示例表:

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

示例查询:

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

现在,查询需要返回一个DataExists"列,如果 blob 为空则返回 0,否则返回 1.

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

这一切正常,但我想知道它的效率如何.即 SQL 服务器是否需要将整个 blob 读入其内存,或者是否有一些优化,以便它只进行足够的读取来确定 blob 是否为空?

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,在此示例中,sp_tableoption行外大值类型"选项设置为 OFF).

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

推荐答案

它使用 NULL 位图.所以没有.

这篇关于检查空 varbinary(max) 列的效率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆