Page 1 of 1

TZTable to read fewer records at a time

Posted: 11.12.2008, 21:44
by rfwoolf
My customer says he has over 2,000 contacts in his contacts table. Is there a way in Delphi to tell the TZtable to only read a few hundred records at a time to display in the DBGrid, and when the user scrolls down it will ask the TZTable to read the next few hundred?

Re: TZTable to read fewer records at a time

Posted: 12.12.2008, 19:22
by skydvrz
rfwoolf wrote:My customer says he has over 2,000 contacts in his contacts table. Is there a way in Delphi to tell the TZtable to only read a few hundred records at a time to display in the DBGrid, and when the user scrolls down it will ask the TZTable to read the next few hundred?
I used to use ZTables for my DB applications until I ran into your problem. Only mine was more like 2,000,000 records in a table. :shock: Swallowing that whole took forever, especially over a WAN. Now I use ZQueries almost exclusively.

I use a ZQuery and an SQL "LIMIT" command to limit the number of records returned in the dataset. You can then page through your table by bumping the start record in the SQL statement.

Example:

Get the first 100 records:

select *
from reallybigtable
limit 0,100

Get the next 100 records:

select *
from reallybigtable
limit 100,100

And so on...

This works in MySQL for sure. It will probably work in other SQL engines, maybe with a minor syntax tweak. For extra credit you can turn on data compression to speed up large data transfers over a WAN - at least on MySQL.

HTH!

Kevin

Posted: 12.12.2008, 20:03
by gto
The syntax for limiting the results in firebird is:

Code: Select all

select first x, y from table
This is very recommended as a best pratice in development process. By the way, 2000 records aren't too much, in my point of view. If your table don't have much columns and your network should be fast, maybe, there's a hardware problem.

Also, in ZQuery there's an option which *probably* will do the fetching thing, called FetchCount or something like that ;)

Posted: 13.12.2008, 11:13
by mdaems
Also have a look at the patch here.

Not for the 6.6 version however. There you'll have to patch manually.

Mark

Posted: 29.12.2008, 21:14
by patyi
Hi all !

Here is the patch for Zeos 6.6.4-stable !

Just unpack and copy-replace this files to zeos/src/components and
(it is good practice to make backup !)
recompile zeos components ...

Now You have FetchRow property and FetchAll method on ZTable and ZQuery components ...

Have fun ! :lol:

Posted: 31.12.2008, 11:05
by mdaems
Somebody else using this and very happy about it? With some positive votes I'm prepared to insert it into a 6.6 maintenance release.

Mark