CActiveDataProvider pagination and force set itemcount


I have some specific problem. My criteria are very heavy and i need only search some records without count all items. I have item count in cache(I use xcache).

for tests I trying this:

   $criteria->limit = 20;

        $CActiveDataProvider = new CActiveDataProvider($this, array(

            'criteria' => $criteria,


            'pagination' => array(

            'pageSize' => isset($_GET['pageSize']) ? (int) $_GET['pageSize'] : 20,

            'ItemCount' => 6,



			//'pagination' => false,

            'sort' => $sort,

            'totalItemCount' => $this->countCandidate()


        return $CActiveDataProvider;

Is there a way to bypass the counting of records and set them manually in pagination?

I am afraid you might not able to achieve that with ActiveDataProvider I could be wrong it has been a while since I have touched yii 1. but I know you can use SqlDataProvider if you want control over the count query and items query.

here this might help you