Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread EDBDataAdapter vs EDBDataReader
Thu, Feb 12 2009 6:11 AMPermanent Link

"Hedley Muscroft"
Another .NET question (sorry!).

I just want to get a canned DataTable. With EDB running in local mode, is
there any preference between :-

     EDBDataAdapter adap = new EDBDataAdapter(sql, Connection);
     DataTable tbl = new DataTable();
     adap.Fill(Table);

and

     EDBCommand cmd = new EDBCommand(sql, Connection);
     EDBDataReader rdr = (EDBDataReader)cmd.ExecuteReader();
     DataTable tbl = new DataTable();
     Table.Load(rdr);

Some C/S ADO.NET providers recommend that a DataReader is faster for simply
retrieving data (something to do with getting a one-way read-only cursor
IIRC). Is there any difference/preference with ElevateDB running in LOCAL
mode?

Thanks!
Fri, Feb 13 2009 2:42 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Hedley,

<< Some C/S ADO.NET providers recommend that a DataReader is faster for
simply retrieving data (something to do with getting a one-way read-only
cursor IIRC). Is there any difference/preference with ElevateDB running in
LOCAL mode? >>

No.  In fact, I'm not sure what they're referring to, since a Fill() will
simply result in a temporary EDBDatareader being created for the purposes of
reading in the data.  The only way to read data in .NET is through a
DataReader descendant.

--
Tim Young
Elevate Software
www.elevatesoft.com

Sat, Feb 14 2009 1:52 AMPermanent Link

"Hedley Muscroft"
Hi Tim,

>> No.  In fact, I'm not sure what they're referring to

The DataReader vs DataAdapter debate has been around for a few years. If
you're just interested in canned data, MS recommend DataReader for
performance reasons :-
http://msdn.microsoft.com/en-us/library/ms254931.aspx

See also :-
http://www.lhotka.net/weblog/DataAdapterFillPreferableToDataReader.aspx
http://aspalliance.com/articleViewer.aspx?aId=626&pId=-1
http://dizastix.com/DataAdatersVsDataReaders.aspx

I imagine that any performance difference is marginal and probably depends
largely on how the ADO.NET provider is coded and on the specifics of the
database engine in question.

>> a Fill() will simply result in a temporary EDBDatareader being
>> created for the purposes of reading in the data

OK, so with EDB there won't be any difference - that's what I was looking
for - thanks!
Sat, Feb 14 2009 9:17 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Hedley,

<< The DataReader vs DataAdapter debate has been around for a few years. If
you're just interested in canned data, MS recommend DataReader for
performance reasons :-
http://msdn.microsoft.com/en-us/library/ms254931.aspx

See also :-
http://www.lhotka.net/weblog/DataAdapterFillPreferableToDataReader.aspx >>

The "performance issue" that you're referring to appears to be strictly
related to what you intend to do with the data.  IOW, the Fill method will
fill an in-memory dataset with the data from the DataReader.  If you didn't
want the data in the in-memory dataset to begin with, then you might get
better performance from skipping that layer.

This whole "controversy" seems a little silly to me.  A DataReader is for
reading the data, period.  A DataAdapter is for reading *and*
storing/manipulating the data, and uses a DataReader to do the work of
getting the source data to start with.  It's like comparing apples and apple
cores.

BTW, the EDBDataAdapter is nothing but a wrapper around the base
DBDataAdapter class.  We don't add any functionality at all.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image