PC Review


Reply
Thread Tools Rate Thread

Converting DataReader to a DataTable Performance issue

 
 
Varangian
Guest
Posts: n/a
 
      7th Sep 2006
Hi all,

the question I want to ask if the conversion of a DataReader to a Table
looping through the DataReader is better than using the Fill Method of
the DataAdapter... I'm asking because internally the DataAdapter uses
the DataReader... so whats the deal of writing a method that converts a
DataReader into a DataTable ?

Thanks!

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      7th Sep 2006
Varangian,
Beats me. If it ain't broke, why fix it?
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




"Varangian" wrote:

> Hi all,
>
> the question I want to ask if the conversion of a DataReader to a Table
> looping through the DataReader is better than using the Fill Method of
> the DataAdapter... I'm asking because internally the DataAdapter uses
> the DataReader... so whats the deal of writing a method that converts a
> DataReader into a DataTable ?
>
> Thanks!
>
>

 
Reply With Quote
 
Varangian
Guest
Posts: n/a
 
      7th Sep 2006
what do you mean ?


Peter wrote:
> Varangian,
> Beats me. If it ain't broke, why fix it?
> Peter
>
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
>
>
> "Varangian" wrote:
>
> > Hi all,
> >
> > the question I want to ask if the conversion of a DataReader to a Table
> > looping through the DataReader is better than using the Fill Method of
> > the DataAdapter... I'm asking because internally the DataAdapter uses
> > the DataReader... so whats the deal of writing a method that converts a
> > DataReader into a DataTable ?
> >
> > Thanks!
> >
> >


 
Reply With Quote
 
Mel
Guest
Posts: n/a
 
      7th Sep 2006
Why don't you make two test functions and time it using TimeSpan. It
really does depend on the size of the database, location of database, number
of records requested and numerous other things.



"Varangian" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi all,
>
> the question I want to ask if the conversion of a DataReader to a Table
> looping through the DataReader is better than using the Fill Method of
> the DataAdapter... I'm asking because internally the DataAdapter uses
> the DataReader... so whats the deal of writing a method that converts a
> DataReader into a DataTable ?
>
> Thanks!
>



 
Reply With Quote
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      7th Sep 2006
What I meant was, you are correct that the DataAdapter already does this
internally, and it works just fine. In the big scheme of things, the time
difference is inconsequential.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




"Varangian" wrote:

> what do you mean ?
>
>
> Peter wrote:
> > Varangian,
> > Beats me. If it ain't broke, why fix it?
> > Peter
> >
> > --
> > Co-founder, Eggheadcafe.com developer portal:
> > http://www.eggheadcafe.com
> > UnBlog:
> > http://petesbloggerama.blogspot.com
> >
> >
> >
> >
> > "Varangian" wrote:
> >
> > > Hi all,
> > >
> > > the question I want to ask if the conversion of a DataReader to a Table
> > > looping through the DataReader is better than using the Fill Method of
> > > the DataAdapter... I'm asking because internally the DataAdapter uses
> > > the DataReader... so whats the deal of writing a method that converts a
> > > DataReader into a DataTable ?
> > >
> > > Thanks!
> > >
> > >

>
>

 
Reply With Quote
 
Varangian
Guest
Posts: n/a
 
      7th Sep 2006
well its always better in making it faster

DataAdapter are always slow compared to the DataReader

I made a test with about 8000 records first with the DataAdapter and
then the DataReader (building a table), on how long it took on each..
each round representing TotalMilliseconds for a TimeSpan from Start of
execution till End

DataAdapter
1) 701
2) 801
3) 741

DataReader
1) 831
2) 791
3) 871

there seems to be a minor difference ..though I found with my test (is
thsi correct?) that the DataAdapter is faster than the DataReader
(minimal ok)

thanks anyway


Peter Bromberg [ C# MVP ] wrote:
> What I meant was, you are correct that the DataAdapter already does this
> internally, and it works just fine. In the big scheme of things, the time
> difference is inconsequential.
> Peter
>
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
>
>
> "Varangian" wrote:
>
> > what do you mean ?
> >
> >
> > Peter wrote:
> > > Varangian,
> > > Beats me. If it ain't broke, why fix it?
> > > Peter
> > >
> > > --
> > > Co-founder, Eggheadcafe.com developer portal:
> > > http://www.eggheadcafe.com
> > > UnBlog:
> > > http://petesbloggerama.blogspot.com
> > >
> > >
> > >
> > >
> > > "Varangian" wrote:
> > >
> > > > Hi all,
> > > >
> > > > the question I want to ask if the conversion of a DataReader to a Table
> > > > looping through the DataReader is better than using the Fill Method of
> > > > the DataAdapter... I'm asking because internally the DataAdapter uses
> > > > the DataReader... so whats the deal of writing a method that converts a
> > > > DataReader into a DataTable ?
> > > >
> > > > Thanks!
> > > >
> > > >

> >
> >


 
Reply With Quote
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      8th Sep 2006
Well! Thanks for confirming my theme that "if it ain't broke, don't fix it.".
There could also be inconsistencies in your test code, which you didn't
post. But the point is, why get hung up over 1/10 of a second (unless it's
something you are doing 100,000 times in a row...)
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




"Varangian" wrote:

> well its always better in making it faster
>
> DataAdapter are always slow compared to the DataReader
>
> I made a test with about 8000 records first with the DataAdapter and
> then the DataReader (building a table), on how long it took on each..
> each round representing TotalMilliseconds for a TimeSpan from Start of
> execution till End
>
> DataAdapter
> 1) 701
> 2) 801
> 3) 741
>
> DataReader
> 1) 831
> 2) 791
> 3) 871
>
> there seems to be a minor difference ..though I found with my test (is
> thsi correct?) that the DataAdapter is faster than the DataReader
> (minimal ok)
>
> thanks anyway
>
>
> Peter Bromberg [ C# MVP ] wrote:
> > What I meant was, you are correct that the DataAdapter already does this
> > internally, and it works just fine. In the big scheme of things, the time
> > difference is inconsequential.
> > Peter
> >
> > --
> > Co-founder, Eggheadcafe.com developer portal:
> > http://www.eggheadcafe.com
> > UnBlog:
> > http://petesbloggerama.blogspot.com
> >
> >
> >
> >
> > "Varangian" wrote:
> >
> > > what do you mean ?
> > >
> > >
> > > Peter wrote:
> > > > Varangian,
> > > > Beats me. If it ain't broke, why fix it?
> > > > Peter
> > > >
> > > > --
> > > > Co-founder, Eggheadcafe.com developer portal:
> > > > http://www.eggheadcafe.com
> > > > UnBlog:
> > > > http://petesbloggerama.blogspot.com
> > > >
> > > >
> > > >
> > > >
> > > > "Varangian" wrote:
> > > >
> > > > > Hi all,
> > > > >
> > > > > the question I want to ask if the conversion of a DataReader to a Table
> > > > > looping through the DataReader is better than using the Fill Method of
> > > > > the DataAdapter... I'm asking because internally the DataAdapter uses
> > > > > the DataReader... so whats the deal of writing a method that converts a
> > > > > DataReader into a DataTable ?
> > > > >
> > > > > Thanks!
> > > > >
> > > > >
> > >
> > >

>
>

 
Reply With Quote
 
Varangian
Guest
Posts: n/a
 
      11th Sep 2006
What possible issues did I miss in this test? I just looped through the
datareader and build a row for each record in the DataTable ..

yes I agree with your point.. but in some situations.. its better
winning that 1 second


Peter wrote:
> Well! Thanks for confirming my theme that "if it ain't broke, don't fix it.".
> There could also be inconsistencies in your test code, which you didn't
> post. But the point is, why get hung up over 1/10 of a second (unless it's
> something you are doing 100,000 times in a row...)
> Peter
>
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
>
>
> "Varangian" wrote:
>
> > well its always better in making it faster
> >
> > DataAdapter are always slow compared to the DataReader
> >
> > I made a test with about 8000 records first with the DataAdapter and
> > then the DataReader (building a table), on how long it took on each..
> > each round representing TotalMilliseconds for a TimeSpan from Start of
> > execution till End
> >
> > DataAdapter
> > 1) 701
> > 2) 801
> > 3) 741
> >
> > DataReader
> > 1) 831
> > 2) 791
> > 3) 871
> >
> > there seems to be a minor difference ..though I found with my test (is
> > thsi correct?) that the DataAdapter is faster than the DataReader
> > (minimal ok)
> >
> > thanks anyway
> >
> >
> > Peter Bromberg [ C# MVP ] wrote:
> > > What I meant was, you are correct that the DataAdapter already does this
> > > internally, and it works just fine. In the big scheme of things, the time
> > > difference is inconsequential.
> > > Peter
> > >
> > > --
> > > Co-founder, Eggheadcafe.com developer portal:
> > > http://www.eggheadcafe.com
> > > UnBlog:
> > > http://petesbloggerama.blogspot.com
> > >
> > >
> > >
> > >
> > > "Varangian" wrote:
> > >
> > > > what do you mean ?
> > > >
> > > >
> > > > Peter wrote:
> > > > > Varangian,
> > > > > Beats me. If it ain't broke, why fix it?
> > > > > Peter
> > > > >
> > > > > --
> > > > > Co-founder, Eggheadcafe.com developer portal:
> > > > > http://www.eggheadcafe.com
> > > > > UnBlog:
> > > > > http://petesbloggerama.blogspot.com
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > "Varangian" wrote:
> > > > >
> > > > > > Hi all,
> > > > > >
> > > > > > the question I want to ask if the conversion of a DataReader to a Table
> > > > > > looping through the DataReader is better than using the Fill Method of
> > > > > > the DataAdapter... I'm asking because internally the DataAdapter uses
> > > > > > the DataReader... so whats the deal of writing a method that converts a
> > > > > > DataReader into a DataTable ?
> > > > > >
> > > > > > Thanks!
> > > > > >
> > > > > >
> > > >
> > > >

> >
> >


 
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
Using a DataTable instead of a DataReader =?Utf-8?B?am9uZWZlcg==?= Microsoft ADO .NET 7 26th Sep 2006 05:08 AM
Filling a DataTable with a DataReader =?Utf-8?B?SlQ=?= Microsoft ADO .NET 0 10th Oct 2005 06:40 AM
DataReader to DataTable... =?Utf-8?B?VGltOjouLg==?= Microsoft ASP .NET 3 18th Jul 2005 02:46 PM
Performance issue: Update a particular column in large DataTable Ajit Kumar Goel Microsoft Dot NET Compact Framework 1 17th Nov 2004 09:51 PM
System.Data.DataTable Performance Issue Buddy Microsoft C# .NET 8 20th Aug 2003 07:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:33 AM.