Page 1 of 1

which is faster?

Posted: Sat 17 Mar 2007 02:05
by anwar5218
With 'FilterSQL' (TmyTable) and use SQL statement (TmyQuery), which is faster?

example:
x := TmyTable.Create(nil);
x.tablename := 'stock';
x.filtersql := 'Reff=20';
x.open;

y := tmyQuery.create(nil)
y.sql.text := 'select reff, name from stock where reff=20';
y.open;

x or y is faster?

Re: which is faster?

Posted: Sat 17 Mar 2007 04:18
by eduardosic
anwar5218 wrote:With 'FilterSQL' (TmyTable) and use SQL statement (TmyQuery), which is faster?

example:
x := TmyTable.Create(nil);
x.tablename := 'stock';
x.filtersql := 'Reff=20';
x.open;

y := tmyQuery.create(nil)
y.sql.text := 'select reff, name from stock where reff=20';
y.open;

x or y is faster?
"Y" is more Faster, because MySQL Server return only Row where Reff=20.

"X", MySQL return all records and the filter is applied in the client Side, but all records are transfered on the network.

Re: which is faster?

Posted: Mon 19 Mar 2007 05:21
by anwar5218
ok. thanks

Posted: Mon 19 Mar 2007 13:24
by Antaeus
x or y is faster?
The second way (with y) should be a bit faster because you have restricted field list in the SELECT statement. The second way will be much faster if there is a BLOB field that is not required on the client in the stock table. In the first case all the fields from the table will be retrieved from the server.
In both cases filtering is performed on the server.