I'm currently dealing with performance/memory consumption optimizations of our application. One of the tasks to perform is to replace all blobs in the a table that correspond to empty arrays with null values; this should reduce db size, memory consumption and speed up the load. Here is the table definition:
CREATE TABLE [dbo].[SampleTable](
[id] [bigint] NOT NULL,
[creationTime] [datetime] NULL,
[binaryData] [image] NULL,
[isEvent] [bit] NULL,
[lastSavedTime] [datetime] NULL,
CONSTRAINT [PK_SampleTable] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
I updated the table and replaced image field values (binaryData) with NULL values where appropriate (data corresponding to empty arrays in the application). Now, I observe the performance deterioration when running trivial SELECT * FROM SampleTable.
Originally those fields that had been updated had length = 512 bytes, not sure if it matters, though.
Any ideas why selecting blobs containing NULL values takes longer than selecting real binary data even if the data is the same for different rows?