gpt4 book ai didi

performance - 为什么 Delphi 中的 ADO Next 记录处理速度变慢?

转载 作者:行者123 更新时间:2023-12-03 15:06:33 27 4
gpt4 key购买 nike

我有一个多年前开发的 Delphi 4 程序,它使用 Opus DirectAccess按顺序搜索 Microsoft Access 数据库并检索所需的记录。 Delphi 4 没有 ADO,所以这就是我使用 DirectAccess 的原因。

但我现在已升级到 Delphi 2009 并将程序转换为使用 ADO。我发现,遍历表(大约 100,000 条记录)的循环开始时与 DirectAccess 中一样快,但随后开始减慢,并且在遍历表时变得越来越慢。基本循环是:

ArticlesTable.First;
while not Cancel and not ArticlesTable.Eof do begin

( See if the current record has criteria desired )
( If so, process the record )

ArticlesTable.Next;
end;

所以基本上,它只是使用 .Next 方法按顺序处理记录。

那么为什么它会变慢,我该如何重新编码才能使它不会变慢?

最佳答案

如果您没有在数据集上使用数据库感知控件,则应该对所有 ADO 数据集调用 DisableControls。

否则速度很糟糕。

引用this article了解详情。

或者,使用内部 ado 记录集属性

while Not ADOQuery1.Recordset.EOF do
begin
ADOQuery1.Recordset.Movenext;
end;

关于performance - 为什么 Delphi 中的 ADO Next 记录处理速度变慢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1496283/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com