how to get count of total record I'm using drupal pagination here i have add some part of my code pagination is working perfect while I'm trying to get the total no of record it is always displaying 10. As i understand i have set the limit 10 so it displaying only total 10

$query-&gt;orderBy('r.published_date', 'DESC');
        $pager = $query-&gt;extend('Drupal\Core\Database\Query\PagerSelectExtender')-&gt;limit(10);
    $results = $pager-&gt;execute()-&gt;fetchAll();


This $results variable I'm getting data with the set of 10 values. 

I would like to display total no of data for that i have created other variable where i have directly executed query in $result so it could give total no of records but its not working it displaying only 10 

$result = $query-&gt;execute();
        while($data = $result-&gt;fetchObject()){
           $count_ret[]=$data-&gt;published_date;
        }
             $total=count($count_ret);


please  guide me where i'm doing wrong
Until the issue Convert pager.inc to a service is solved you find the pager information still in global variables:

global $pager_page_array, $pager_total, $pager_total_items, $pager_limits;

$count_of_total_records = $pager_total_items[$element];


Where $element defaults to '0' if this is the first pager with no element id set.