Performance of TIBCQuery during select?
Posted: Thu 12 Dec 2013 15:16
I am working with TIBCQuery to enhance the performance of select statements, having previously used the TQuery of BDE. The thought was to use the FetchAll mode to load the entire query at once, instead of requesting the records one at a time, to minimize the database access overhead.
So far I've experienced that the time required to traverse the query is reduced, but that the time required to retrieve the query is increased, much as expected. However, the net time from the query is sent to data is read is almost the same in both cases
Here's what I do:
Is there a way to get better performance on my reads? As I said earlier, I have tried with FetchAll and uni/bi directional modes, as well as tried a few different values for BlockReadSize using fetchall=false
So far I've experienced that the time required to traverse the query is reduced, but that the time required to retrieve the query is increased, much as expected. However, the net time from the query is sent to data is read is almost the same in both cases
Here's what I do:
Code: Select all
procedure TForm4.Button2Click(Sender: TObject);
var
Q : TQuery;
QIbc : TIBCQuery;
Dummy : integer;
BeginTime : real;
EndTIme : real;
VT : TVirtualTable;
Loader : TIBCLoader;
i : integer;
Param : TParam;
begin
if CheckBOx1.Checked then begin
Q := TQuery.Create(nil);
try
Q.DatabaseName := FDatabase.DatabaseName;
Q.SQL.Add('Select * from MODELQUERY543875505');
Q.Open;
Q.First;
BeginTime := Now;
while not(Q.Eof) do begin
Dummy := Q.Fields[0].AsInteger;
Dummy := Q.Fields[1].AsInteger;
Dummy := Q.Fields[2].AsInteger;
Dummy := Q.Fields[3].AsInteger;
Dummy := Q.Fields[4].AsInteger;
Dummy := Q.Fields[5].AsInteger;
Dummy := Q.Fields[6].AsInteger;
Dummy := Q.Fields[7].AsInteger;
Dummy := Q.Fields[8].AsInteger;
Dummy := Q.Fields[9].AsInteger;
Q.Next;
end;
EndTime := NOw;
Label1.Caption := IntToStr(Round(Q.RecordCount/((EndTime-BeginTime)*86400)));
finally
Q.Free;
end;
end else begin
QIBC := TIBCQuery.Create(nil);
QIbc.FetchAll := True;
QIBC.UniDirectional := False;
try
QIbc.Connection := Self.IBCConnection;
QIbc.SQL.Add('Select * from MODELQUERY543875505 ');
QIbc.Open;
QIbc.First;
//VT := TVirtualTable.Create(nil);
//Loader := TIBCLoader.Create(nil);
//Loader.Connection := Self.IBCConnection;
//Loader.
BeginTime := Now;
I := 1;
while not(QIBC.Eof) do begin
Dummy := QIbc.Fields[0].AsInteger;
Dummy := QIbc.Fields[1].AsInteger;
Dummy := QIbc.Fields[2].AsInteger;
Dummy := QIbc.Fields[3].AsInteger;
Dummy := QIbc.Fields[4].AsInteger;
Dummy := QIbc.Fields[5].AsInteger;
Dummy := QIbc.Fields[6].AsInteger;
Dummy := QIbc.Fields[7].AsInteger;
Dummy := QIbc.Fields[8].AsInteger;
Dummy := QIbc.Fields[9].AsInteger;
QIbc.Next;
end;
EndTime := NOw;