which is faster?

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
anwar5218
Posts: 11
Joined: Tue 13 Dec 2005 11:02

which is faster?

Post by anwar5218 » Sat 17 Mar 2007 02:05

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?

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

Re: which is faster?

Post by eduardosic » Sat 17 Mar 2007 04:18

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.

anwar5218
Posts: 11
Joined: Tue 13 Dec 2005 11:02

Re: which is faster?

Post by anwar5218 » Mon 19 Mar 2007 05:21

ok. thanks

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Mon 19 Mar 2007 13:24

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.

Post Reply