Search All Articles Submit your Website or Blog to A New Internet Library
Monday, January 26, 2009
Why is DataSet slower than DataReader ?
Following are the major differences between “DataSet” and “DataReader” :-
- “DataSet” is a disconnected architecture, while “DataReader” has live connection while reading data. If we want to cache data and pass to a different tier “DataSet” forms the best choice and it has decent XML support.
- When application needs to access data from more than one table “DataSet” forms the best choice.
- If we need to move back while reading records, “datareader” does not support this functionality.
- But one of the biggest drawbacks of DataSet is speed. As “DataSet” carry considerable overhead because of relations, multiple tables etc speed is slower than “DataReader”. Always try to use “DataReader” wherever possible, as it’s meant specially for speed performance.
Subscribe to:
Post Comments (Atom)
Also Read other Top Articles
- JSON Serialization in VS 2008
- Implementing Forms Authentication in Silverlight Application.
- Making GridView Rows or Individual Cells Clickable and Selectable.
- Enabling browser back button for GridView Paging and Sorting in Ajax 1.1 and 3.5 (using Visual Studio 2005/ Visual studio 2008)
- How to pass values from User Control to Page or calling Page methods from User Control.
- What is WCF?
- New features in C# 4.0
- C# to VB.NET and VB.NET to C# online free converter tools.


2 comments:
If you need the data disconnected, what's preferable between a dataset or iterating through the datareader and mapping data to classes and insert to an array?
Hi Portablenut...
TDataReader has the least amount of overhead, and is faster.
It also has some issues which DataSet and DataTable do not, such as being
read-only, forward-only, and necessitating that a Connection remain opened
dring its entire lifetime. DataSets and DataTables are disconnected Record
Sets. The DataSet is also implicitly serializable as XML. With dataset u can perform certain operations like filtering, editing, sorting...
If we are using DataReader we should not forget to use command behaviour.CloseConnection attribute to close connection attached to DataReader when we close it. (important when u r transfering reader to other layer where u can't get connection object to close it)
or best thing is to use Using Statement (If possible).
Post a Comment
Post your comments/questions/feedback for this Article.