FetchRows + FetchAll + UniDirectional

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
dnvw72
Posts: 2
Joined: Mon 18 Feb 2008 21:59

FetchRows + FetchAll + UniDirectional

Post by dnvw72 » Mon 18 Feb 2008 22:46

Before discovering the UniDirectional property, the amount of memory being used by a TMyQuery was very high. Setting this property solved that problem.

Now, is there a way to cache ONLY n rows at a time instead of one row at a time? For example, I would like to bring in 25 rows and after looping through that set of 25 (via TMyQuery.Next), the TMyQuery grabs another 25 and discards the previous 25. This process continues until TMyQuery.EOF. This should keep the amount of memory used by a TMyQuery object lower than fetching all rows and reduce network trips to the MySQL database, which resides on a different server on the network.

Thanks,

Damon

GuzunNicolae
Posts: 78
Joined: Wed 17 Jan 2007 14:16

Post by GuzunNicolae » Tue 19 Feb 2008 13:40

You have already answered to your question in post subject.

Just set FetchAll to False and FetchRows to whatever you want (25 in your case).

But be careful to the limitations of setting FetchAll to False. Read about them in MyDAC manual.

dnvw72
Posts: 2
Joined: Mon 18 Feb 2008 21:59

Post by dnvw72 » Tue 19 Feb 2008 14:38

Thanks for confirming my question. I figured the TMyQuery would grow by 25 records at a time.

-- Damon

GuzunNicolae
Posts: 78
Joined: Wed 17 Jan 2007 14:16

Post by GuzunNicolae » Tue 19 Feb 2008 15:33

If you set UniDirectional to True then only one record will be cached at the moment. So you may even go through mlns of records w/o having your application grow in size.

There is a thread on this forum about this.

Post Reply