Page 1 of 1

DataReader behaves as DataSet (too much time & memory)

Posted: Thu 28 Jul 2011 13:21
by ishguy
Hi,

I am using dotConnect Universal Professional 3.20.54.0 to connect to a Postgres SQL server. I am opening a reader to it and logging data to a file. However, a strange thing is going on. When the "ExecuteReader()" executes, it takes a long time (in several minutes) and the memory climbs to a staggering value.

It is as if the Reader is actually acting like a DataSet, it first pulls entire data to client machine and then processes it by going to the next statement. DataReaders are supposed to be lightweight otherwise. The table in question contains 2mil records. Sample code is given below.

Code: Select all


string conn_str = "Provider=PostgreSQL; Server=192.168.1.50; Port=5432; Database=company; User ID=sys;  Pooling=true; Connection Lifetime=86400; Connection Timeout=360;";
UniConnection ucon = new UniConnection(conn_str);
UniCommand ucmd = new UniCommand("select * from mytable", ucon);
UniDataReader ured = null;

ucon.Open();
ured = ucmd.ExecuteReader(); // this line eats time+mem
int i = 0;

while (ured.Read())
{
i++;
System.Diagnostics.Debug.WriteLine(string.Format("{0} --> {1}", i, ured[0]));
// Code to write data to a log file
}

ured.Close();
ucon.Close();


I am new to Devart. Is this behavior expected?

Posted: Mon 01 Aug 2011 14:06
by Shalex
ishguy wrote:It is as if the Reader is actually acting like a DataSet, it first pulls entire data to client machine and then processes it by going to the next statement. DataReaders are supposed to be lightweight otherwise.
Thank you for your report. We will investigate the possibility of implementing UniCommand.FetchAll property (like PgSqlCommand.FetchAll) and notify you about the results as soon as possible.

Re: DataReader behaves as DataSet (too much time & memory)

Posted: Mon 09 Nov 2015 12:19
by jkort
Hi,

I would also like UniCommand to have a FetchAll property.

Regards,

Jan

Re: DataReader behaves as DataSet (too much time & memory)

Posted: Thu 12 Nov 2015 17:12
by Shalex
Please use the "Default Fetch All=false;" connection string parameter which controls the behaviour of the corresponding command instance. Does this help?

Re: DataReader behaves as DataSet (too much time & memory)

Posted: Tue 26 Jan 2016 09:01
by jkort
It works great, but the exact spelling is important:

Default FetchAll=false