Performance - Datareader vs. Dataset

A

Andre T.

This is more of a curious observation than anything else.
We were in a scenario where we needed to pull about 1000
records from the database. We only needed read access, so
we used a datareader because it was supposed to perform
better.

As we ran that app, we discovered that the datareader was
pretty slow looping through it's records...It was
accounting for about 65% of the total page processing
time. We thought that there were maybe too many records,
so we set up a test to see how a dataset would perform.

After we ran several test runs, we found almost no
difference in performance at all...we're talking less than
one-half of 1% (0.3521 sec versus 0.3529 sec - average
over 100 test trials). The allocation of processing time
is completely different (the dataset uses it's bulk
pulling the data while the datareader uses it's bulk
looping through it's records), but overall performance is
the same.

Does anyone know anything about this? I thought for
read/forward-only access datareaders were supposed to be
faster? Any input would be appreciated. Thanks.

Andre T

P.S. We also ran a test pulling about 250 records, and the
results were the same.
 
S

Scott M.

It's not just a matter of performance. There is less overhead in memory
with a DataReader. It's a thinner class and has less of a footprint than a
DataSet does. So, while (on your system), they performed about equal, that
doesn't mean they weren't eating up different amounts of memory on the heap.
 
C

Chris Taylor

Hi,

The DataAdapter uses a DataReader internally to enumerate the records and
populate the DataSet, this can be confirmed by looking at the
DbDataAdapter.FillLoadDataRowChunk() method. The larger the resultset is the
more visible the performance impact will be on populating the DataSet.

Hope this helps

Chris Taylor
 
W

William Ryan

I totally agree with the observations Scott and Chris made. With 100
records, you wouldn't expect there to be a huge difference b/c both happen
so fast that any difference would be trivial (I'm sure there are extreme
situations where this may not hold, but by and large this is the case).

If you look at larger sets, you'll see profound differences.

Check out this link
http://www.vb2themax.com/HtmlDoc.asp?Table=Articles&ID=510 They did quite a
few tests and the results are quite telling...
 

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