PreviousNext
Help > Appendices > FAQ > Common Problems FAQ > My application is too slow, how to tune it up ?
My application is too slow, how to tune it up ?

Here are some rules that can help to speed up an Easycom application:

 

1. TTable <-> TQuery

 

TTable is faster because it uses Record-level accesses. It uses the key fields in native mode.

So TQuery should only be used when TTable usage is impossible. You even can create additional logicals (with select/omit for example) to avoid Tquery.

TQuery and TTable are allways faster when used in Read/Only mode. So if you don't need to update your data, always select the Readonly mode to your components (ReadOnly:=true for TTable, and Requestlive:=false for TQuery).

 

2. Setrange <-> Filters <-> OnFilterRecord

 

 

This is important to know how these different filtering features are working:

- SetRange is a record-level action (it relay on Key fields defined in IndexFieldNames).

- Filter generates an OPNQRYF each time the filter expression is changed.

- OnFilterRecord is a local filtering. It means that all records will be read.

 

So, always prefer a SetRange (or SetRangeStart ...) to filters.

 

The filter is powerful when you only have to filter with always the same expression. But if you want to change often the filter expression it can be a little bit slow. It also can be slow if you often deactivate/activate the filter.

 

How to solve this situation?

You can combine a SetRange with an OnFilterRecord. The setrange clause will eliminate most records, and OnFilterRecord will only eliminate some others.

Of course, in some cases, filter property will be very useful. Just be careful to not have a filter on each TTable component!

 

3. DBLookupComboBox

 

To tune your DBLookupComboBox, be careful to have a keyField for the ListSource that is the keyfield in your TTable. If your list source is a 'Detail TTable', best is to have a key that involves the masterfields and the key to your list source.

 

Example :

 

You have 3 files:

- COMPANY (COMP_ID, COMP_NAME, ...)

- PEOPLE ( COMP_ID, PEOPL_ID, PEOPL_NAME, ...)

- COUNTRY ( COUNT_ID, COUNT_NAME, ...)

 

Imagine you want to have a DBLookUpCombo for choosing somebody (POEPLE file) of the COMPANY, and another to choose a COUNTRY. Of course, COMPANY is a MasterSource of PEOPLE on the COMP_ID field.

You will have best results if you choose the correct IndexFieldNames for PEOPLE and COUNTRY files:

 

PEOPLE : COMP_ID;PEOPL_ID

COUNTRY :  COUNT_ID

 

However, just select PEOPL_ID in the DblookupComboBox component.

So, COMP_ID will be used for the Master/Detail relationship (as a partial key), and PEOPL_ID will be used for the DBLoopUpCombo.

 

 NB: if you don't select the right IndexFieldNames (for example COMP_ID instead of COMP_ID;PEOPL_ID), Delphi will generate filters to mach the record, and it will be more slow (the result will be the same, but slower).