DataReader behaves as DataSet (too much time & memory)

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for universal data access
Post Reply
ishguy
Posts: 1
Joined: Thu 28 Jul 2011 13:09

DataReader behaves as DataSet (too much time & memory)

Post by ishguy » Thu 28 Jul 2011 13:21

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?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 01 Aug 2011 14:06

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.

jkort
Posts: 5
Joined: Mon 09 Nov 2015 12:06

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

Post by jkort » Mon 09 Nov 2015 12:19

Hi,

I would also like UniCommand to have a FetchAll property.

Regards,

Jan

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

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

Post by Shalex » Thu 12 Nov 2015 17:12

Please use the "Default Fetch All=false;" connection string parameter which controls the behaviour of the corresponding command instance. Does this help?

jkort
Posts: 5
Joined: Mon 09 Nov 2015 12:06

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

Post by jkort » Tue 26 Jan 2016 09:01

It works great, but the exact spelling is important:

Default FetchAll=false

Post Reply