tags:

views:

1535

answers:

3

Hi, i have two applications (server and client), that uses TQuery connected with TClientDataSet through TDCOMConnection, and in some cases clientdataset opens about 300000 records and than application throws exception "Temporary table resource limit".

Is there any workaround how to fix this? (except "do not open such huge dataset"?)

update: oops i'm sorry there is 300K records, not 3 millions..

+2  A: 

You have the answer already. Don't open such a huge dataset in a ClientDataSet (CDS).

Three million rows in a CDS is a huge memory load (depending on the size of each row, it can be gigantic).

The whole purpose of using a CDS is to work quickly with small datasets that can be manipulated in memory. Adding that many rows is ridiculous; use a real dataset instead, or redesign things so you don't need to retrieve so many rows at a time.

Ken White
error not in TClientDataSet - it's BDE bug, so it is TQuery, and theres 300K records.
Jk
+1  A: 

over 3 million records is way too much to handle at once. My guess is that you are performing an export or something like that which requires that many records to be sent down the wire. One method you could use to reduce this issue would be to have the middle-tier generate an export file, and then deliver that file to the client (preferably compressing first using ZLIB or something simular).

If you are pulling data back to the client for viewing purposes, then consider sending summary information only, and then allowing the client to dig thier way thru the data a portion at a time. The users would thank you because your performance will go way up and they won't have to dig thru records they don't care about looking at.

EDIT

Even 300,000 records is way too much to handle at once. If you had that many pennies, would you be able to carry them all? But if you made it into larger denominations, you could. if your sending data to the client for a report, then I strongly suggest a summary method... give them the large picture and let them drill slowly into the data. send grouped data and then let them open up slowly.

If this is a search results screen, then set a limit of the number of records to be returned + 1. For example to display 100 records, set the limit to 101. Still only display 100, the last record means that there were MORE than 100 records so the customer needs to adjust thier search criteria to return a smaller subset.

skamradt
+1  A: 

The error might be from the TQuery rather than the TClientDataSet. When using a TQuery it creates a temporary table and it might be this limit that you are hitting. However in saying this, loading 3,000,000 records into a TClientDataSet is a bad idea also as it will try to load every record into memory - which maybe possible if they are only a few bytes each but it is probably still going to kill your machine (obviously at 1kb each you are going to need 3GB of RAM minimum).

You should try to break your data into smaller chunks. If it is the TQuery failing this will mean adjusting the SQL (fewer fields / fewer records) or moving to a better database (the BDE is getting a little tired after all).

Alister
Yep it's tquery, but theres 300K records, unfortunally i can't move from BDE (this is old and big project) and i can't move to "better" database (it is oracle :))
Jk