May I add that the most βefficientβ way to get the total number of records, especially in a large table, is to save the total as a number in another table. This way you do not need to query the whole table every time you want to get the total.
However, you need to configure the code or triggers in the database to increase or decrease this number when adding / removing a row.
Thus, this is not the easiest way, but if your site is growing, you should definitely think about it.
Jonathan
source share