If we want total record count from a query having pagination we need to run the count query.
I think the PagerDefault class already running a count query.If we can catch this in a member variable then we can avoid the multiple running of the count query.

Here I can explain the details
In includes/pager.inc line 74
$total_items = $this->getCountQuery()->execute()->fetchField();

We can set one public variable and assign $total_items to it.This way we can avoid the multiple running of the count query.

Thanks,
Naushad

Comments

Jaypan’s picture

Ok.