From cbd3d2c165d46b5cdcbecb4e424902abcca1db91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Espi=C3=A9?= Date: Tue, 16 Jan 2018 08:46:49 +0000 Subject: [PATCH] =?UTF-8?q?Retrofit=20from=20trunk=20N=C2=B01026=20-=20Por?= =?UTF-8?q?tal=20requests=20are=20too=20slow=20*=20Counts=20on=20union=20r?= =?UTF-8?q?equests=20are=20more=20optimized=20*=20Requests=20for=20combo?= =?UTF-8?q?=20box=20values=20are=20more=20optimized=20[from=20revision=205?= =?UTF-8?q?249]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SVN:2.4[5250] --- core/dbunionsearch.class.php | 27 +++++++++++++------ .../bsselectobjectfieldrenderer.class.inc.php | 1 + 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/core/dbunionsearch.class.php b/core/dbunionsearch.class.php index 07f2b8cee..d2c07fb7d 100644 --- a/core/dbunionsearch.class.php +++ b/core/dbunionsearch.class.php @@ -496,19 +496,30 @@ class DBUnionSearch extends DBSearch $aSearchSelectedClasses[$sSearchAlias] = $this->aSelectedClasses[$sAlias]; } - if (is_null($aAttToLoad)) + if ($bGetCount) { - $aQueryAttToLoad = null; + // Select only ids for the count to allow optimization of joins + foreach($aSearchAliases as $sSearchAlias) + { + $aQueryAttToLoad[$sSearchAlias] = array(); + } } else { - // (Eventually) Transform the aliases - $aQueryAttToLoad = array(); - foreach ($aAttToLoad as $sAlias => $aAttributes) + if (is_null($aAttToLoad)) { - $iColumn = array_search($sAlias, $aAliases); - $sQueryAlias = ($iColumn === false) ? $sAlias : $aSearchAliases[$iColumn]; - $aQueryAttToLoad[$sQueryAlias] = $aAttributes; + $aQueryAttToLoad = null; + } + else + { + // (Eventually) Transform the aliases + $aQueryAttToLoad = array(); + foreach($aAttToLoad as $sAlias => $aAttributes) + { + $iColumn = array_search($sAlias, $aAliases); + $sQueryAlias = ($iColumn === false) ? $sAlias : $aSearchAliases[$iColumn]; + $aQueryAttToLoad[$sQueryAlias] = $aAttributes; + } } } diff --git a/sources/renderer/bootstrap/fieldrenderer/bsselectobjectfieldrenderer.class.inc.php b/sources/renderer/bootstrap/fieldrenderer/bsselectobjectfieldrenderer.class.inc.php index c2d05a828..e770aaede 100644 --- a/sources/renderer/bootstrap/fieldrenderer/bsselectobjectfieldrenderer.class.inc.php +++ b/sources/renderer/bootstrap/fieldrenderer/bsselectobjectfieldrenderer.class.inc.php @@ -103,6 +103,7 @@ class BsSelectObjectFieldRenderer extends FieldRenderer $oOutput->AddHtml(''); // - Retrieving choices $oChoicesSet = new DBObjectSet($oSearch); + $oChoicesSet->OptimizeColumnLoad(array($oSearch->GetClassAlias() => array('friendlyname'))); while ($oChoice = $oChoicesSet->Fetch()) { // Note : The test is a double equal on purpose as the type of the value received from the XHR is not always the same as the type of the allowed values. (eg : string vs int)