PC Review


Reply
Thread Tools Rate Thread

Performance to copy blob from SqlDataReader

 
 
Roy
Guest
Posts: n/a
 
      4th May 2008
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[]>.

 
Reply With Quote
 
 
 
 
Mary Chipman [MSFT]
Guest
Posts: n/a
 
      4th May 2008
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

On Sat, 3 May 2008 19:45:00 -0700, Roy <(E-Mail Removed)>
wrote:

>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[]>.

 
Reply With Quote
 
Roy
Guest
Posts: n/a
 
      4th May 2008
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 [MSFT]" wrote:

> 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
>
> On Sat, 3 May 2008 19:45:00 -0700, Roy <(E-Mail Removed)>
> wrote:
>
> >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[]>.

>

 
Reply With Quote
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      5th May 2008
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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: SqlDataReader performance WenYuan Wang Microsoft ADO .NET 8 20th Dec 2006 08:22 AM
Re: SqlDataReader performance Marina Levit [MVP] Microsoft ADO .NET 0 11th Dec 2006 03:35 PM
Re: SqlDataReader performance Shawn B. Microsoft ADO .NET 0 10th Dec 2006 05:21 AM
Re: SqlDataReader performance William \(Bill\) Vaughn Microsoft ADO .NET 0 8th Dec 2006 06:52 PM
Re: SqlDataReader performance Yves. L. Microsoft ADO .NET 0 8th Dec 2006 02:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:43 PM.