LookupFields are very bad implemented! (Perfomance quite bad)


I'm very disappointed with the implementation of the calculated and
lookupfields. The perfomance is quite bad because of their design. I
have found that the calculated event is called every time a field of
the dataset changes (well, that's ok, but I have write a TQuery
descendent that enables me to call a procedure when the fields I want
changes). The bad news are that the lookupfields are searched
everytime a field changes also!. The logic says to me that this is an
important waste of time and the method used to get the value (Lookup)
is quite slow. I get my app 3 times faster just finding the record
with a SELECT sentence only when the keyfield changes. Another little
improvement is to have a little cache associated to the lookup field
and get it filled with the records that are accessed (next time,
instead of going to the database get the value from the cache) but
this has a problem when the value being searched changes in the
database. The best solution is to find it only when the keyfield
changes its value (and use a SELECT instead of Lookup!!!)

Also I would like to see in next version of Delphi another type of
field (Data, InternalCalc, Calculated, Lookup AND CustomData). This
new type of field should be use to store data not calculated, not
lookup and not associated to the database (calculated fields aren't
usefull because they can only get a value on a OnCalcField event).

In general, I have found that there are several querys to the database
that can be avoided, with a signficant improvement of the performance.