diff --git a/core/modules/views/src/Plugin/views/pager/Mini.php b/core/modules/views/src/Plugin/views/pager/Mini.php
index 5f1750e..c5cf39a 100644
--- a/core/modules/views/src/Plugin/views/pager/Mini.php
+++ b/core/modules/views/src/Plugin/views/pager/Mini.php
@@ -47,14 +47,17 @@ public function summaryTitle() {
   public function query() {
     parent::query();
 
-    // Don't query for the next page if we have a pager that has a limited
-    // amount of pages.
-    if ($this->getItemsPerPage() > 0 && (empty($this->options['total_pages']) || ($this->getCurrentPage() < $this->options['total_pages']))) {
-      // Increase the items in the query in order to be able to find out whether
-      // there is another page.
-      $limit = $this->view->query->getLimit();
-      $limit += 1;
-      $this->view->query->setLimit($limit);
+    // Only modify the query if we don't want to do a total row count
+    if (!$this->view->get_total_rows) {
+      // Don't query for the next page if we have a pager that has a limited
+      // amount of pages.
+      if ($this->getItemsPerPage() > 0 && (empty($this->options['total_pages']) || ($this->getCurrentPage() < $this->options['total_pages']))) {
+        // Increase the items in the query in order to be able to find out whether
+        // there is another page.
+        $limit = $this->view->query->getLimit();
+        $limit += 1;
+        $this->view->query->setLimit($limit);
+      }
     }
   }
 
@@ -69,19 +72,15 @@ public function useCountQuery() {
    * {@inheritdoc}
    */
   public function postExecute(&$result) {
-    // In query() one more item might have been retrieved than necessary. If so,
-    // the next link needs to be displayed and the item removed.
-    if ($this->getItemsPerPage() > 0 && count($result) > $this->getItemsPerPage()) {
-      array_pop($result);
-      // Make sure the pager shows the next link by setting the total items to
-      // the biggest possible number but prevent failing calculations like
-      // ceil(PHP_INT_MAX) we take PHP_INT_MAX / 2.
-      $total = PHP_INT_MAX / 2;
+    // Only modify the result if we didn't do a total row count
+    if (!$this->view->get_total_rows) {
+      $this->total_items = $this->getCurrentPage() * $this->getItemsPerPage() + count($result);
+      // query() checks if we need a next link by setting limit 1 record past this page
+      // If we got the extra record we need to remove it before we render the result
+      if ($this->getItemsPerPage() > 0 && count($result) > $this->getItemsPerPage()) {
+        array_pop($result);
+      }
     }
-    else {
-      $total = $this->getCurrentPage() * $this->getItemsPerPage() + count($result);
-    }
-    $this->total_items = $total;
   }
 
   /**
