TZTable to read fewer records at a time

Forum related to Firebird

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
rfwoolf
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 28.09.2008, 20:46

TZTable to read fewer records at a time

Post 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?
skydvrz
Fresh Boarder
Fresh Boarder
Posts: 13
Joined: 15.12.2005, 22:56
Location: Olympia, WA USA
Contact:

Re: TZTable to read fewer records at a time

Post 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
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post 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 ;)
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
Image
patyi
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 12.11.2005, 21:57

Post 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:
You do not have the required permissions to view the files attached to this post.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
Image
Post Reply