totalItemCount in CSqlDataPOrovider and CArrayDataProvider

Why do we still need to supply totalItemCount?

Which one is the best practical and fastest way to supply totalItemCount? using count() [php method] or separate sql queryScalar() ?

TIA

Daniel