HANA supports a large variety of table types, e.g. ROW-, COLUMN-, VIRTUAL-, EXTENDED-, and MULTISTORE-tables come to mind here.
For some of those, the current raw record count is kept as part of the internal storage structures and does not need to computed upon query time.
This is specifically true for ROW and COLUMN tables.
VIRTUAL tables are on the extreme other end and behave a lot more like complex views when it comes to SELECT count(*)
. Depending on the DB "behind" the virtual table, the performance of this can vary wildly!
Also, be careful assuming that ROW and COLUMN store tables will return the information with nearly no effort. HANA is a shared-nothing distributed database (in scale-out setups), which means that this kind of information is only known to the node that a table is located on. Finding out the row count of, e.g. a partitioned table with X partitions on Y number of nodes can take a considerable amount of time!
Finally, this raw record count is only available for tables that are currently in memory. Running a SELECT count(*)
on a table that is currently unloaded will trigger the load of the columns that are required to answer that query (basically all primary key columns + some internal table management structures).
In the ideal case (a column table, loaded to memory and all partitions on a single node) this query should return instantaneous; but the other mentioned scenarios need to be considered, too.
Hope that answers the rather broad question.