Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > datareader vs. dataset

Reply
Thread Tools

datareader vs. dataset

 
 
Bihn
Guest
Posts: n/a
 
      03-09-2005
I was reading about datareader which is said to be slimmer & faster then
dataset. Since the datareader have to go fetching the dat from the database
every time it need it, the data it gets then should be up to date. However,
both the IbuySpy and Duwamish samples and most, if not all, the shopping
cart sample codes I've seen use dataset to implement the opration for
ecommerce sites. So is the trip that the datareader need to go fetch the
data from the database is too much a performance drag or is using the
dataset is "the way" to implement the ecommerce site? Will keeping the
information up-to-date present a problem because the dataset is a
disconnected data access control? Anyone who has implemt ecommerce site
please give me opinion as to which data access control is more suitable to
use to implement an ecommerce site.
Thanks.


 
Reply With Quote
 
 
 
 
Lucas Tam
Guest
Posts: n/a
 
      03-09-2005
"Bihn" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> I was reading about datareader which is said to be slimmer & faster
> then dataset. Since the datareader have to go fetching the dat from
> the database every time it need it, the data it gets then should be up
> to date. However, both the IbuySpy and Duwamish samples and most, if
> not all, the shopping cart sample codes I've seen use dataset to
> implement the opration for ecommerce sites. So is the trip that the
> datareader need to go fetch the data from the database is too much a
> performance drag or is using the dataset is "the way" to implement the
> ecommerce site? Will keeping the information up-to-date present a
> problem because the dataset is a disconnected data access control?
> Anyone who has implemt ecommerce site please give me opinion as to
> which data access control is more suitable to use to implement an
> ecommerce site. Thanks.



The value of a dataset is somewhat diminished in a web environment
because each time the webpage loads the dataset is refreshed anyways. I
prefer to use a datareader whenever possible because:

1. Datareaders use a lot less memory
2. Data readers are faster

Becareful when using a dataset with a large amount of data - you'll suck
up all of the server's resources. Datasets are best for filter/sorting
small sets of data.

--
Lucas Tam ((E-Mail Removed))
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      03-10-2005
This is a half truth. DataSets can be cached while data readers can't,
which nullifies your concern about DataSets....I would consider the
disconnected, and hence cached, nature of datasets the primary factor to
favor them over pure DataReaders. In some situations (even within the same
application) one method is better than the other. In other words the
question is pretty hard to answer since it's very situational.

As for keeping the DataSet up to date, the DataAdapters and DataTable
contain some pretty nice functionality for maintaining state dispite their
disconnected fashion.

There are a lot of alternatives to both DataSets and DataReaders which I'd
highly recommend for large scale systems. I just finished writing an
article which you might find useful:
http://msdn.microsoft.com/asp.net/de...CustEntCls.asp

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)


"Lucas Tam" <(E-Mail Removed)> wrote in message
news:Xns9614BE0BC7ECBnntprogerscom@127.0.0.1...
> "Bihn" <(E-Mail Removed)> wrote in
> news:(E-Mail Removed):
>
> > I was reading about datareader which is said to be slimmer & faster
> > then dataset. Since the datareader have to go fetching the dat from
> > the database every time it need it, the data it gets then should be up
> > to date. However, both the IbuySpy and Duwamish samples and most, if
> > not all, the shopping cart sample codes I've seen use dataset to
> > implement the opration for ecommerce sites. So is the trip that the
> > datareader need to go fetch the data from the database is too much a
> > performance drag or is using the dataset is "the way" to implement the
> > ecommerce site? Will keeping the information up-to-date present a
> > problem because the dataset is a disconnected data access control?
> > Anyone who has implemt ecommerce site please give me opinion as to
> > which data access control is more suitable to use to implement an
> > ecommerce site. Thanks.

>
>
> The value of a dataset is somewhat diminished in a web environment
> because each time the webpage loads the dataset is refreshed anyways. I
> prefer to use a datareader whenever possible because:
>
> 1. Datareaders use a lot less memory
> 2. Data readers are faster
>
> Becareful when using a dataset with a large amount of data - you'll suck
> up all of the server's resources. Datasets are best for filter/sorting
> small sets of data.
>
> --
> Lucas Tam ((E-Mail Removed))
> Please delete "REMOVE" from the e-mail address when replying.
> http://members.ebay.com/aboutme/coolspot18/



 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      03-10-2005
in a e-comm sites datareaders should be avoided for serveral reasons

1) the overhead of a dataset or datatable if single result set is low over a
datareader
2) a dataset will hold read locks for less time than a datareader in most
cases
3) unless you are very careful in wrapping all datareader accesses with
onerror handling to do the close you will have a resource leak.
4) unit tests are easier to write with datasets
5) thru typed datasets you can catch coding error ate compile time
6) its a really bad practice for a function to return a datareader, so it
can be hard to properly structure code

-- bruce (sqlwork.com)




"Lucas Tam" <(E-Mail Removed)> wrote in message
news:Xns9614BE0BC7ECBnntprogerscom@127.0.0.1...
| "Bihn" <(E-Mail Removed)> wrote in
| news:(E-Mail Removed):
|
| > I was reading about datareader which is said to be slimmer & faster
| > then dataset. Since the datareader have to go fetching the dat from
| > the database every time it need it, the data it gets then should be up
| > to date. However, both the IbuySpy and Duwamish samples and most, if
| > not all, the shopping cart sample codes I've seen use dataset to
| > implement the opration for ecommerce sites. So is the trip that the
| > datareader need to go fetch the data from the database is too much a
| > performance drag or is using the dataset is "the way" to implement the
| > ecommerce site? Will keeping the information up-to-date present a
| > problem because the dataset is a disconnected data access control?
| > Anyone who has implemt ecommerce site please give me opinion as to
| > which data access control is more suitable to use to implement an
| > ecommerce site. Thanks.
|
|
| The value of a dataset is somewhat diminished in a web environment
| because each time the webpage loads the dataset is refreshed anyways. I
| prefer to use a datareader whenever possible because:
|
| 1. Datareaders use a lot less memory
| 2. Data readers are faster
|
| Becareful when using a dataset with a large amount of data - you'll suck
| up all of the server's resources. Datasets are best for filter/sorting
| small sets of data.
|
| --
| Lucas Tam ((E-Mail Removed))
| Please delete "REMOVE" from the e-mail address when replying.
| http://members.ebay.com/aboutme/coolspot18/


 
Reply With Quote
 
Chris R. Timmons
Guest
Posts: n/a
 
      03-10-2005
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in news:(E-Mail Removed):

> I just
> finished writing an article which you might find useful:
> http://msdn.microsoft.com/asp.net/de...=/library/en-u
> s/dnaspp/html/CustEntCls.asp


Karl,

Nice article, but I draw the line at "demoralizing" my database !

(look for the phrase "demoralization for performance"...)

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
 
Reply With Quote
 
Matt Berther
Guest
Posts: n/a
 
      03-10-2005
Hello Karl,

> There are a lot of alternatives to both DataSets and DataReaders which
> I'd highly recommend for large scale systems. I just finished writing
> an article which you might find useful:
> http://msdn.microsoft.com/asp.net/de...rary/en-us/dna
> spp/html/CustEntCls.asp


Thank you for an absolutely wonderful argument and some very compelling reasons
to use entity objects. I've known that this is the right way to go for a
while. Your article though will help to convince my co-workers. :=)

--
Matt Berther
http://www.mattberther.com



 
Reply With Quote
 
Lucas Tam
Guest
Posts: n/a
 
      03-10-2005
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in news:(E-Mail Removed):

> DataSets can be cached while data readers can't,
> which nullifies your concern about DataSets....


Is caching provided out of the box in .NET?

And how much memory would a large dataset use?

--
Lucas Tam ((E-Mail Removed))
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
 
Reply With Quote
 
Karl Seguin
Guest
Posts: n/a
 
      03-10-2005
Hahah...thx I've asked for it to be fixed...I do that all the
time...normally my gf picks it up...I should take the word "demoralize" out
of Word's dictionary and then it'll complain

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)


"Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message
news:Xns9614F2BA3EA84crtimmonscrtimmonsin@207.46.2 48.16...
> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
> net> wrote in news:(E-Mail Removed):
>
> > I just
> > finished writing an article which you might find useful:
> > http://msdn.microsoft.com/asp.net/de...=/library/en-u
> > s/dnaspp/html/CustEntCls.asp

>
> Karl,
>
> Nice article, but I draw the line at "demoralizing" my database !
>
> (look for the phrase "demoralization for performance"...)
>
> --
> Hope this helps.
>
> Chris.
> -------------
> C.R. Timmons Consulting, Inc.
> http://www.crtimmonsinc.com/



 
Reply With Quote
 
Karl Seguin
Guest
Posts: n/a
 
      03-10-2005
Lucas:

Yes, you can use Page.Cache.Insert("someKey", someValue)

and you can specify all types of parameters such as dependencies, time,
priority...

Your 2nd question is impossible to answer...really, how large as we talking?
It isn't just a matter of rows but also of how much information in those
rows....

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)


"Lucas Tam" <(E-Mail Removed)> wrote in message
news:Xns96151D60121BFnntprogerscom@127.0.0.1...
> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
> wrote in news:(E-Mail Removed):
>
> > DataSets can be cached while data readers can't,
> > which nullifies your concern about DataSets....

>
> Is caching provided out of the box in .NET?
>
> And how much memory would a large dataset use?
>
> --
> Lucas Tam ((E-Mail Removed))
> Please delete "REMOVE" from the e-mail address when replying.
> http://members.ebay.com/aboutme/coolspot18/



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      03-10-2005
It takes a DataReader to create a DataSet. You never see it (it's
encapsulated), but it's there. So, obviously, the DataReader is going to be
faster than the DataSet. HOWEVER,

1. Speed isn't everything. DataReaders have persistent connections, so they
can't be cached. Fetching the same data twice is going to be more expensive
than fetching it once and caching it, regardless.
2. You didn't mention DataTable. A DataSet is comprised of one or more
DataTables. Therefore, a DataTable has less overhead than a DataSet. Unless
you need all the functionality of a DataSet, a DataTable is faster for
cached data.
3. Sample code doesn't usually indicate the best way of doing something. Its
purpose is to demonstrate technology. The reasons for using different types
of classes might be as simple as wanting to introduce you to one or more of
them. You can't rely on Sample code to recommend technique.

In conclusion, you might just as well ask which gear in your transmissin is
"better." At 5 miles per hour, the high gears aren't going to push the car.
At high speeds, the low gears will rip apart the transmission. It's the same
with DataSets, DataTable, and DataReaders. Obviously (to me) Microsoft
created all 3 data containers for a reason, and anticipated that, at one
time or another, all of them would be useful. The best one is the one that
is best in the current situation.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Bihn" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I was reading about datareader which is said to be slimmer & faster then
> dataset. Since the datareader have to go fetching the dat from the
> database
> every time it need it, the data it gets then should be up to date.
> However,
> both the IbuySpy and Duwamish samples and most, if not all, the shopping
> cart sample codes I've seen use dataset to implement the opration for
> ecommerce sites. So is the trip that the datareader need to go fetch the
> data from the database is too much a performance drag or is using the
> dataset is "the way" to implement the ecommerce site? Will keeping the
> information up-to-date present a problem because the dataset is a
> disconnected data access control? Anyone who has implemt ecommerce site
> please give me opinion as to which data access control is more suitable to
> use to implement an ecommerce site.
> Thanks.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
datareader vs dataset =?Utf-8?B?cm9kY2hhcg==?= ASP .Net 4 11-07-2005 04:46 PM
Datareader, dataset, else? Patreek ASP .Net 2 09-21-2005 12:56 PM
How to use a datareader instead of a dataset? Shapper ASP .Net 2 04-25-2005 02:43 PM
DataSet versus DataReader. Which one to use? Thank You. Shapper ASP .Net 2 04-22-2005 12:29 AM
DataSet paging vs Datareader paging =?Utf-8?B?UGF0cmljay5PLklnZQ==?= ASP .Net 1 10-08-2004 02:13 PM



Advertisments