From 8c46207f3243af36e20efe3d219c7c3ab805c4fd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Oct 2022 14:25:21 +0200 Subject: [PATCH] Use the fast count method --- htdocs/societe/list.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 8fbc763bd64..735149947e3 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -691,11 +691,20 @@ $sql .= $hookmanager->resPrint; // Count total nb of records with no order and no limits $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); + /*$resql = $db->query($sql); if ($resql) { $nbtotalofrecords = $db->num_rows($resql); } else { dol_print_error($db); + }*/ + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); } if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0