How It Works: Statistics Sampling for BLOB data

I worked on an interesting issue today and the outcome deserves a post.  The issue was that when auto update statistics executed the query went from 6 seconds to 6+ minutes. select count(*) from tblImageData where blobData is null Turing on the SP-:StmtStarting and SP:StmtCompleted trace events the internal sample query can be retrieved. SELECT StatMan ( [SC0] ) FROM ( SELECT TOP 100 PERCENT SUBSTRING ( [logo] , 1 , 100 )++ substring ( [blobData] ,           case when datalength ( [blobData] )<= 200  then 101             else datalength ( [blobData] )- 99 end ,             datalength ( [blobData] )) AS [SC0] FROM [dbo] .

The rest is here: 
How It Works: Statistics Sampling for BLOB data

Leave a comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>