Performance to copy blob from SqlDataReader

R

Roy

I have a SqlDataReader dr returned from a SqlCommand. dr contains only one
column of 2000 varbinary(max) records (contains 24 bytes in my testing
case). The following code takes 1 second to
run. I would like to improve the performance. Any suggestions

while (dr.Read())
{
list.Add(dr[0] as byte[]);
}

where list is of List<byte[]>.
 
R

Roy

I don't think it is the List.Add(...). I have tested by replacing the list
with an array and it does not affect. I think the bottleneck is the copy of
the bytes from data reader to a local. I don't know which is the way for best
performance for a data reader column with underlining varbinary(max) type.

Mary Chipman said:
I don't know where the bottleneck is -- possibly the list? This topic
describes different coding techniques for retrieving varbinary(max)
data:

http://msdn.microsoft.com/en-us/library/a1904w6t(VS.80).aspx

--Mary

I have a SqlDataReader dr returned from a SqlCommand. dr contains only one
column of 2000 varbinary(max) records (contains 24 bytes in my testing
case). The following code takes 1 second to
run. I would like to improve the performance. Any suggestions

while (dr.Read())
{
list.Add(dr[0] as byte[]);
}

where list is of List<byte[]>.
 
C

Cor Ligthert[MVP]

Roy,
I don't think it is the List.Add(...). I have tested by replacing the list
with an array and it does not affect. I think the bottleneck is the copy
of
the bytes from data reader to a local. I don't know which is the way for
best
performance for a data reader column with underlining varbinary(max) type.

If that would be the case, then why not with an integer, however in my idea
can reading blobs as they have a little bit large size be terible slow.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top