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?
FetchAll
before returning RecordCount
.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.SELECT COUNT(*)
. FetchAll or not FetchAll will be better to control explicitly. This is how this is done in AnyDAC (more).