Re: ADO vs ADO Express Time Trials (redux)



I'm curious...

Is

FName := VarAsString(Recordset.Fields.Item['Name']) ;

Faster than

FName := VarAsString(Recordset.Fields['Name']) ;

?

-Steve-

"Ian Boyd" <ian.borlandnews010@xxxxxxxxxxxx> wrote in message
news:4777f4e9$1@xxxxxxxxxxxxxxxxxxxxxxxxx

Summary

Your database work will be 80% faster if you change any code that is of
the form:
procedure GetValuesFromQuery(Query: TADOQuery);
begin
FName := Query.FieldByName('Name').AsString;
FAddress := Query.FieldByName('Address').AsString;
...
end;

to

procedure GetValuesFromQuery(Query: TADOQuery);
begin
GetValuesFromRecordset(Query.Recordset);
end;

procedure GetValuesFromRecordset(Recordset: ADOInt._Recordset);
begin
FName := VarAsString(Recordset.Fields.Item['Name']);
FAddress := VarAsString(Recordset.Fields.Items['Address']);
...
end;

ADO Express is much slower than ADO. Even ADO hobbled with by name field
lookups is faster than ADO Express by ordinal. You can use ADO Express to
open a query, but as soon as you do bypass anything written by Borland and
go straight to the
ADOQuery.Recordset

to perform all your field and value lookups. The largest single
performance penalty is trying to access a field value in ADO Express. ADO
Express provides to way to access a field's underlying Variant value.
Because of this, you have to access the field through the
Query.Recordset.Fields collection.



i originally posted this 2 years ago (http://tinyurl.com/33ygmg). It was
time to revisit it because i was once again trying to make things faster,
and i forgot a lot of the specifics that i had discovered.



.



Relevant Pages

  • How to save DateTime
    ... I'm using D5, TADOQuery and MSSQL200. ... I want to know what is the correct way to save a date not datetime into a ... This is my old wy which use to work in BDE but now does not work with ADO ...
    (borland.public.delphi.database.ado)
  • ADO vs ADO Express Time Trials (redux)
    ... ADO Express: 8.3 seconds ... Test 4a: Field Lookup by Ordinal ... Loop: 0.45s ... procedure GetValuesFromQuery(Query: TADOQuery); ...
    (borland.public.delphi.database.ado)
  • Re: ADO patch for D5? EOF BOF error.
    ... do you know where I can find these ADO patches? ... >> After looping through the results of a simple select query (tADOQuery), ... > unpatched D5 ADO with MDAC 2.6 or later and the second ADO patch fixed it. ...
    (borland.public.delphi.database.ado)