JSWork
JSWork

Reputation: 1035

Are datareaders still faster than datasets?

I've been coding with .NET since it came out of beta. That's a long time and I should reexamine some of my assumptions to see if things changed.

One of my biggest assumptions is that datareader is faster than a dataset - http://www.sitepoint.com/dataset-datareader/

Is this still the case? Did anything change? I heard rumors there is something less "chatty" than datareaders now but can't find any articles to back it up. The idea was that when i "readnext" I have to do a database round trip while the alternative grabs everything at once in a single trip.

Is there a faster alternative to datareader now or is the article above still correct?

For the record, when I have a datareader all I do is place row values into an object, place the object into a hashtable, read the next row, repeat, then close the connection. Any logic connecting objects can be done using the hashtables after the connections are closed (freeing up the pool as quickly as possible).

Upvotes: 4

Views: 1828

Answers (3)

Mark Wilkins
Mark Wilkins

Reputation: 41252

The underlying logic of filling a DataSet via a DbDataAdapter object has not changed. It still uses a DbDataReader to fill up the DataSet. So, by definition, using a DataReader for the operation you describe will still be more efficient.

Upvotes: 1

Biff MaGriff
Biff MaGriff

Reputation: 8241

Yes, DataSets are still horribly slow so and you should never use them for any system that has more than 1 user or is a web app.

Upvotes: 1

Erik Funkenbusch
Erik Funkenbusch

Reputation: 93444

DataReaders and DataSets have different sets of functionality. It doesn't matter how fast a DataReader might be if it doesn't have the functionality you need from a DataSet. You're comparing apples and oranges.

If you want an apple, then use an apple, if you want an orange use that. Use the best tool for the job.

Upvotes: 2

Related Questions