如何防止Delphi ADO将整个表加载到内存中? [英] How to prevent Delphi ADO from loading the entire table into memory?
问题描述
我不是Delphi程序员,但是我有一个旧的Delphi 7应用程序,我需要修复它正在使用ADO。
数据库表(MS Accesss )包含+1万行,当我设置ADOTable.Active = true时,它开始将整个表加载到RAM中,这需要大量的内存和时间。
我可以阻止ADO加载整个表吗?我试图设置MaxRecords,但没有帮助。
基本上我们所做的只是安装程序启动:
//连接到数据库
DataModule.MyADOConnection.Connected:= true;
DataModule.MeasurementsADOTable.MaxRecords:= 1;
//打开数据表
DataModule.MeasurementsADOTable.Active:=true;
设置Active = true后,开始将整个测量加载到RAM中,需要TIME! p>
我们正在使用MSDASQL.1提供程序。也许它不支持MaxRecords属性?
如何将一些限制查询添加到此数据对象中,只能从测量中加载TOP 1 *?
您可以使用TADOQuery来使用sql查询来限制结果集。或者您可以使用TADOTable,并设置 CursorLocation 到服务器端光标,以防止客户端将完整的结果集加载到内存中。
I am not a Delphi programmer, but I I got an old Delphi 7 application that I need to fix and it is using ADO.
The database table (MS Accesss) contains +100,000 rows and when I set the ADOTable.Active=true it starts to load the entire table into RAM and that takes a lot of memory and time.
How can I prevent ADO to load the entire table? I tried to set the MaxRecords but it does not help.
Basically all we do is att program startup:
// Connect to database
DataModule.MyADOConnection.Connected:=true;
DataModule.MeasurementsADOTable.MaxRecords:=1;
// Open datatables
DataModule.MeasurementsADOTable.Active:=true;
After setting Active=true it starts to load the entire measurements into RAM and it takes TIME!
We are using the MSDASQL.1 provider. Perhaps it does not support the MaxRecords property?
How do I add some limiting query into this data object to only "load TOP 1 * from Measurements" ?
You could use TADOQuery to limit the result set with a sql query. Or you could use TADOTable and set the CursorLocation to a Server side cursor to prevent the client loading the complete resultset in memory.
这篇关于如何防止Delphi ADO将整个表加载到内存中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!