mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Optimization of SQL queries: fixed!
SVN:trunk[2486]
This commit is contained in:
@@ -145,7 +145,7 @@ class Config
|
||||
'type' => 'bool',
|
||||
'description' => 'For developpers: format the SQL queries for human analysis',
|
||||
'default' => false,
|
||||
'value' => true,
|
||||
'value' => false,
|
||||
'source_of_value' => '',
|
||||
'show_in_conf_sample' => false,
|
||||
),
|
||||
|
||||
@@ -2138,7 +2138,6 @@ abstract class MetaModel
|
||||
}
|
||||
|
||||
$oSelect = self::MakeSelectStructure($oFilter, $aOrderBy, $aArgs, $aAttToLoad, $aExtendedDataSpec, $iLimitCount, $iLimitStart, $bGetCount);
|
||||
$oSelect = unserialize(serialize($oSelect));
|
||||
|
||||
$aScalarArgs = array_merge(self::PrepareQueryArguments($aArgs), $oFilter->GetInternalParams());
|
||||
try
|
||||
@@ -2245,8 +2244,8 @@ abstract class MetaModel
|
||||
if (array_key_exists($sOqlId, self::$m_aQueryStructCache))
|
||||
{
|
||||
// hit!
|
||||
$oSelect = clone self::$m_aQueryStructCache[$sOqlId];
|
||||
// Note: cloning is not enough... should be replaced by unserialize(serialize()) !!!
|
||||
$oSelect = unserialize(serialize(self::$m_aQueryStructCache[$sOqlId]));
|
||||
// Note: cloning is not enough because the subtree is made of objects
|
||||
}
|
||||
elseif (self::$m_bUseAPCCache)
|
||||
{
|
||||
@@ -2284,6 +2283,16 @@ abstract class MetaModel
|
||||
$oSelect->SetSelect($oBuild->m_oQBExpressions->GetSelect());
|
||||
}
|
||||
|
||||
if (self::$m_bOptimizeQueries)
|
||||
{
|
||||
if ($bGetCount)
|
||||
{
|
||||
// Simplify the query if just getting the count
|
||||
$oSelect->SetSelect(array());
|
||||
}
|
||||
$oSelect->OptimizeJoins();
|
||||
}
|
||||
|
||||
$oKPI->ComputeStats('MakeQuery (select)', $sOqlQuery);
|
||||
|
||||
if (self::$m_bQueryCacheEnabled)
|
||||
@@ -2297,17 +2306,6 @@ abstract class MetaModel
|
||||
|
||||
self::$m_aQueryStructCache[$sOqlId] = clone $oSelect;
|
||||
}
|
||||
|
||||
if (self::$m_bOptimizeQueries)
|
||||
{
|
||||
// Simplify the query if just getting the count
|
||||
//
|
||||
if ($bGetCount)
|
||||
{
|
||||
$oSelect->SetSelect(array());
|
||||
}
|
||||
$oSelect->OptimizeJoins();
|
||||
}
|
||||
}
|
||||
|
||||
// Join to an additional table, if required...
|
||||
|
||||
Reference in New Issue
Block a user