From 4af66839da8893fd288140510a87f9b265ecd835 Mon Sep 17 00:00:00 2001 From: Christian Winther Date: Sat, 31 May 2014 20:03:44 +0000 Subject: [PATCH] allow skipping count() for big tables - this can be super slow, if no count is done, return 10k rows as guess to ensure pagination works --- Controller/AuditsController.php | 1 + Model/Audit.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Controller/AuditsController.php b/Controller/AuditsController.php index 8f086c4..f7b54b2 100644 --- a/Controller/AuditsController.php +++ b/Controller/AuditsController.php @@ -37,6 +37,7 @@ public function admin_index() { $Instance = ClassRegistry::init($model); $displayField = $Instance->displayField; + $this->Paginator->settings['do_count'] = empty($Instance->noAuditCount); $this->Paginator->settings['fields'][] = $model . '.' . $displayField; $this->Paginator->settings['joins'][] = [ 'alias' => $model, diff --git a/Model/Audit.php b/Model/Audit.php index 8f3483c..d6a8fd9 100644 --- a/Model/Audit.php +++ b/Model/Audit.php @@ -36,6 +36,10 @@ public function setupSearchPlugin() { * @return integer */ public function paginateCount($conditions, $recursive, $extra) { + if (empty($extra['do_count'])) { + return 10000; + } + return $this->find('count', compact('conditions')); }