Subject Speed up reading every row in an TIB_Cursor
Author Andreas Kanthak
Hallo all.

I have to load every row of a resultset of a TIB_Cursor to
internal structures of my programm. I'am now reading ca. 26000 records
in ~8 seconds. It seems to me, that this could be done faster.
Here is a excerpt of my routine:
(This is running within a thread)
qryThreaded is a TIB_Cursor.

repeat
DoitAgain := False;
Canceled := false;
if assigned(FRestartCallBack) then fRestartCallBack(Self); //Setup/Initialize internal buffers
qryThreaded.Active := false; // Setup the SQL upon users request.
qryThreaded.SQL.Clear;
qryThreaded.SQL.Add(' SELECT EVENTIDX');
qryThreaded.SQL.Add(' , EVENTTIME');
qryThreaded.SQL.Add(' , EVENTHANDLE');
qryThreaded.SQL.Add(' , EVENTUNQUIT');
qryThreaded.SQL.Add(' , EVDATA');
qryThreaded.SQL.Add('FROM EVENTTABLE');
if l1 <> WrongLong then
begin
qryThreaded.SQL.Add('WHERE ');
qryThreaded.SQL.Add('(EVENTTIME >= ' + Inttostr(L1) +
'AND EVENTTIME <= '
+
IntToStr(L2) + ')');
qryThreaded.SQL.Add('OR');
qryThreaded.SQL.Add(' (EVENTUNQUIT = 1)');
end
else
begin
if FOnlyUnquited then
begin
qryThreaded.SQL.Add('WHERE ');
qryThreaded.SQL.Add(' (EVENTUNQUIT = 1)');
end;
end;
qryThreaded.SQL.Add(' ORDER BY EVENTTIME');
qryThreaded.BeginBusy(true);
try
qryThreaded.Execute; //Execute the query

aCol := qryThreaded.FieldByName('EVDATA'); //Get the column of the field we are interested in.
qryThreaded.apiFirst; //get the first record.
Capt := 'Filtern der Ereignisdaten';
Max := qryThreaded.RecordCount;
synchronize(InsPrg); //Setup a progress bar
I := 1;
try
while not qryThreaded.Eof do
begin
if Canceled then Break; //if canceled or...
if DoItAgain then Break; //...the user submitted another query then break this run

ExtractEVFormString(evRec, ACol); //extract the binary data from the field

FLoadCallBack(evRec); // Store it in our internal buffers

qryThreaded.Apinext; // Get next record

Inc(i); //Inform the User about the progress
if i mod 100 = 0 then
synchronize(Progress);
Application.ProcessMessages;
end;
finally
synchronize(DeInstPrg); //remove the progressbar
end;
finally
qryThreaded.EndBusy;
end;
until (DoItAgain = False) or Canceled;

The Line "qryThreaded.Apinext;" seems to consume allmost ~65% of the whole time
needed by this procedure (Tested with Turbopowers Sleuth QA Suite).
Is there a better (and faster) way to perform this task?

Best wishes

Andreas Kanthak