hello,
I use TZQuery to execute a SQL statement like "select * from table ... where ... limit=1000 offset=200" on a mySQL database.
After that I fetch one record of the resultset after the other using TZQuery.Next in a loop.
Is there any possibility to fetch a block of records, for example all 200 records of the resultset?
May be I have to use an other class instead of TZQuery?
Moreover, do you have any hint to a documentation or tutorial, where I can learn more about those details of the behaviour of the ZEOS classes?
Thanks in advance
Stefan.
fetch multiple records
Moderators: gto, cipto_kh, EgonHugeist
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Hi Stefan,
Actual fetching of all data coming from the server happens when opening the dataset. This is done by libmysql.dll. This is why the initial opening of a big resultset may take some time. This is inherent to the use of libmysql, which can only send one resultset at a time and must send all data before an other call to the server can be made.
Fetching the data into the dataset itself can be tuned by setting the (relatively new) FetchRows property. This property is only available in the zeoslib 7.x series (trunk and testing branch or using the snapshots).
You can find the patch and the corresponding talks here : http://zeos.firmos.at/viewtopic.php?t=1857
Now concerning the Next loop : that will always be the only way to fetch data from a dataset. (Unless somebody makes some method to fetch all data in a variant array, like implemented in eg. php)
From the explanation above this doesn't mean a real fetch is done from the server at every 'next' call. Actually, a next just fetches one row from the libmysql buffer and puts in in an internal zeoslib cache.
If you only want to read line by line and never go back in a dataset you could also use a TZReadOnly query. That CAN avoid using the internal zeoslib cache (so only the libmysql cache is used), but this method can be slow when doing certain operations. Read this thread first : http://zeos.firmos.at/viewtopic.php?t=240
Mark
Actual fetching of all data coming from the server happens when opening the dataset. This is done by libmysql.dll. This is why the initial opening of a big resultset may take some time. This is inherent to the use of libmysql, which can only send one resultset at a time and must send all data before an other call to the server can be made.
Fetching the data into the dataset itself can be tuned by setting the (relatively new) FetchRows property. This property is only available in the zeoslib 7.x series (trunk and testing branch or using the snapshots).
You can find the patch and the corresponding talks here : http://zeos.firmos.at/viewtopic.php?t=1857
Now concerning the Next loop : that will always be the only way to fetch data from a dataset. (Unless somebody makes some method to fetch all data in a variant array, like implemented in eg. php)
From the explanation above this doesn't mean a real fetch is done from the server at every 'next' call. Actually, a next just fetches one row from the libmysql buffer and puts in in an internal zeoslib cache.
If you only want to read line by line and never go back in a dataset you could also use a TZReadOnly query. That CAN avoid using the internal zeoslib cache (so only the libmysql cache is used), but this method can be slow when doing certain operations. Read this thread first : http://zeos.firmos.at/viewtopic.php?t=240
Mark