Why does ADO Next post processing slow down in Delphi?

I had a Delphi 4 program that I developed many years ago that used Opus DirectAccess to search the Microsoft Access database sequentially and retrieve the desired records. Delphi 4 did not have ADO, so I used DirectAccess.

But now I upgraded to Delphi 2009 and converted the program to use ADO. I found that a cycle through a table (about 100,000 records) starts as fast as in DirectAccess, but then it starts to slow down and becomes slower and slower when it goes through the table. The main loop:

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;

Basically, it's just processing records sequentially using the .Next method.

So why is this slowing down, and how can I recode this so that it doesn't slow down?

+5
source share
2 answers

You must call DisableControls in all ADO datasets if you are not using the DB controls in the dataset.

Otherwise, the speed sucks.

refer to this article for details.

Alternatively, use the internal ado recordset property

while Not ADOQuery1.Recordset.EOF do
begin
  ADOQuery1.Recordset.Movenext;
end;
+10
source

Alternatively, you can change the CursorType property of your access component (TADOTable / TADOQuery / ...).

ctOpenForwardOnly, ; , DBGrid ( ) .

.

+1

All Articles