Page 1 of 1

What's more Fast???

Posted: Tue 11 Apr 2006 07:59
by eduardosic
What's is more Fast??,in execution

example 1:

with QueryClients do begin
Close;
SQL.Clear;
SQL.Add( 'Select Name From Clients ' );
SQL.Add( 'Where name like ' + '''' + edit1.text + '%' + '''' );
Prepare;
Open;
end;

example 2:

with QueryClients do begin
Close;
SQL.Clear;
SQL.Add( 'Select Name From Clients ' );
SQL.Add( 'Where name like :pParam' );
ParamByName( 'pParam' ).AsString := Edit1.Text + '%';
Prepare;
Open;

end;


which the execution form fastest??

Posted: Tue 11 Apr 2006 09:18
by swierzbicki
Both are the same since this is related to Delphi and not MySQL

Posted: Tue 11 Apr 2006 11:25
by Antaeus
The performance is the same in both cases. But using parameters is more correct.

thanks

Posted: Tue 11 Apr 2006 21:53
by eduardosic
Antaeus wrote:The performance is the same in both cases. But using parameters is more correct.
thanks all.

Posted: Thu 27 Apr 2006 20:20
by ben
why you dont do a JOIN to other table to get all the relative records instead of opening/closing table inside a loop?

Posted: Thu 27 Apr 2006 21:55
by GEswin
ben, afaik he isn't using any loop

Posted: Fri 28 Apr 2006 08:36
by ben
oops I thought it was "while" not with
Sorry