As COUNT queries sometimes are heavy and unnecessary, I’d like to propose to not force the getTotalItemCount in CActiveDataProvider (see line 129).
Currently you can only avoid it if your ADP has no pagination. My proposal is to perform it only if the pagination object has not itemCount already set (e.g. at construction time):
CActiveDataProvider.php:129
+++ if(!$pagination->getItemCount())
$pagination->setItemCount($this->getTotalItemCount());
This allows for more flexibility in the definition of pagination object, e.g. for infinity-scroll-like paginations.
Best, E.