Do ZeosLib DataSets need to perform FetchAll method to return real real total rows?

StackOverflow https://stackoverflow.com/questions/12061267

  •  27-06-2021
  •  | 
  •  

Frage

In Firebird/Interbase databases we have the TIBQuery, TIBTable and TIBDataSet, which have the FetchAll method to count how many rows that data set has. If we don't call that method, these data sets only register as "total" the number of rows that the user already saw by a TDBGrid or TDBNavigator. This "total" can be retrieved by calling the `RecordCount' method of these data sets.

Another (much more efficient) way to get the real total rows it to get a separated data set and perform some SELECT COUNT(*) FROM TABLE_NAME and apply any filters we like. It's Ok by far.

But now that I am working with MySQL through ZeosLib, I was wonder if I need to have that trouble to put a second query on the memory.

We know that ZeosLib makes it's queries and it might return internally the statistics of that query, which includes the number of rows returned.

Does ZeosLib puts that information in the RecordCount or does it works exactly like Interbase Components?

War es hilfreich?

Lösung

  1. Zeos returns number of already fetched records. It does not take into account any applyed filters and does not do FetchAll before returning RecordCount.
  2. SELECT COUNT(*) ... is not "much more efficient", because it creates additional server workload, which sometimes may be equal to workload to execute an original query.
  3. In general, a data access library may offer 3 modes of record count calculation: the number of fetched rows, the number of visible rows (like first, but after applying filters), and SELECT COUNT(*). FetchAll or not FetchAll will be better to control explicitly. This is how this is done in AnyDAC (more).
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top