Page 1 of 1

Bad performace on TZAbstractRODataset when connected to grid

Posted: 04.12.2009, 10:02
by mscherr
Hi.

I'm trying to port a BDE/Firebird 2.1 app to ZEOS.

Using a TZQuery connected to a DBGrid (SMDBGrid but that doesn't matter), opening a table with about 10k records lasts too long.

In the VCL after opening the dataset, TCustomDBGrid.UpdateScrollBar is called which calls Self.VisibleRowCount -> TZAbstractRODataset.GetRecordCount -> TZAbstractRODataset.FetchRows(0) which fetches all the records in...

Code: Select all

...
if RowCount = 0 then
begin
  while FetchOneRow do; // <- !!!
  Result := True;
end
...
...well, so the performance, compared to the old BDE TQuery, is very bad. Even setting FetchRows to i.e. 100 is not optimal because then RecordCount displays only the fetched number of records and not the correct number. There is no way to get these values using the underlying Firebird API like the old BDE components did?

Michael

Posted: 04.12.2009, 11:54
by mdaems
Well, I don't know the FB API very well. But if there's a function that can return the number of available resutls before fetching, it may be possible to implement this.
What should be done then?
- Add a property to the IZDatabaseInfo to indicate if the API supports GetRecordCount (or something similar)
- Add a (usually unsupported) function to the dbcresultset interfaces that uses the right API call from the plain API to retrieve the number of records in the resultset
- Change the Getrecordcount function to use the resultset's new function if the metadata indicates this function is supported.
- Testtesttesttest... I don't know the side effects...

Mark

Re: Bad performace on TZAbstractRODataset when connected to

Posted: 23.01.2010, 08:50
by alexeevd
mscherr wrote:Hi.
There is no way to get these values using the underlying Firebird API like the old BDE components did?

Michael
BDE developed before FB born. TQuery must work like zeos query, but TTable use not-trivial "live" cache on table index and use additional select count(*)... query when access to RecordCount (look to SQLMonitor).