Profiling evolution
Posted: 15.02.2008, 09:51
Hi,
I have tested a little program.
This program :
- connect to Oracle
- use a 'Select' Query
- Use function First in Query object
- check recordcount
- loop for all record with Next function.
The code is
The result give :
Before Select : 9:36:51
After Select: 9:36:51
After First: 9:36:51
After RecordCount: 9:38:02
After for: 9:38:02
I don't understand the elapsed time for the recordcount function.
This is problematic because DBGrid and datasource means using recordcount. It's not possible to receive this value on select function ?
Thank you
gilles
I have tested a little program.
This program :
- connect to Oracle
- use a 'Select' Query
- Use function First in Query object
- check recordcount
- loop for all record with Next function.
The code is
procedure TForm1.Button1Click(Sender: TObject);
var
ZConnection1: TZConnection;
Query1: TZQuery;
Datasource1: TDatasource;
I: Integer;
ICount: Integer;
// Time: TDateTime;
begin
screen.Cursor := crSQLWait;
ZConnection1 := TZConnection.Create(Self);
ZConnection1.Protocol := 'oracle';
ZConnection1.Database := 'HPNDCW5';
ZConnection1.User := 'pnd';
ZConnection1.Password := 'pnd';
ZConnection1.Connect ;
Query1 := TZQuery.Create(Self);
Query1.Connection := ZConnection1;
Query1.Active := false;
Label2.Caption := 'Before Select : ' + TimeToStr(Time);
Query1.SQL.Clear;
Query1.SQL.Add('select NOMSCR,CHPSCR,IDTENT,CHPDIC from cwd16') ;
Query1.Active := true;
Label3.Caption := 'After Select : ' + TimeToStr(Time);
Query1.First;
Label4.Caption := 'After First: ' + TimeToStr(Time);
ICount := Query1.RecordCount;
Label5.Caption := 'After RecordCount: ' + TimeToStr(Time);
for I := 0 to ICount do
begin
// Label1.Caption := Query1.Fields[0].Text;
Query1.Next;
end;
Label6.Caption := 'After for : ' + TimeToStr(Time);
{ Datasource1 := TDatasource.Create(Self) ;
Datasource1.AutoEdit := false;
Datasource1.Enabled := true;
Datasource1.DataSet := Query1;
DBGrid1.DataSource := Datasource1;
}
screen.Cursor := crDefault;
end;
The result give :
Before Select : 9:36:51
After Select: 9:36:51
After First: 9:36:51
After RecordCount: 9:38:02
After for: 9:38:02
I don't understand the elapsed time for the recordcount function.
This is problematic because DBGrid and datasource means using recordcount. It's not possible to receive this value on select function ?
Thank you
gilles