From cae4526b3bf1301eff39e778365bfd3cff08e258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Espi=C3=A9?= Date: Tue, 27 Feb 2018 15:54:30 +0000 Subject: [PATCH] Performance enhancement. Avoid multiple count requests. SVN:trunk[5373] --- core/dbobjectset.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/dbobjectset.class.php b/core/dbobjectset.class.php index e5d21df4e..438f5ea5a 100644 --- a/core/dbobjectset.class.php +++ b/core/dbobjectset.class.php @@ -634,7 +634,6 @@ class DBObjectSet implements iDBObjectSetIterator $this->m_oSQLResult->free(); $this->m_oSQLResult = null; } - $this->m_iNumTotalDBRows = null; try { @@ -666,11 +665,12 @@ class DBObjectSet implements iDBObjectSetIterator } if ($this->m_oSQLResult === false) return; - - if (($this->m_iLimitCount == 0) && ($this->m_iLimitStart == 0)) + + if ((($this->m_iLimitCount == 0) || ($this->m_iLimitCount > $this->m_oSQLResult->num_rows)) && ($this->m_iLimitStart == 0)) { $this->m_iNumTotalDBRows = $this->m_oSQLResult->num_rows; } + $this->m_iNumLoadedDBRows = $this->m_oSQLResult->num_rows; } @@ -714,7 +714,7 @@ class DBObjectSet implements iDBObjectSetIterator $aRow = CMDBSource::FetchArray($resQuery); CMDBSource::FreeResult($resQuery); - $this->m_iNumTotalDBRows = $aRow['COUNT']; + $this->m_iNumTotalDBRows = intval($aRow['COUNT']); } return $this->m_iNumTotalDBRows + count($this->m_aAddedObjects); // Does it fix Trac #887 ??