N°1420 - Performances enhancement

SVN:trunk[5833]
This commit is contained in:
Eric Espié
2018-06-07 15:06:38 +00:00
parent 5b2f32c08a
commit 70a0a3c52e
14 changed files with 300 additions and 113 deletions

View File

@@ -638,6 +638,20 @@ abstract class MetaModel
return reset($aAttributes);
}
/**
* Returns the list of attributes composing the friendlyname
*
* @param $sClass
*
* @return array
*/
final static public function GetFriendlyNameAttributeCodeList($sClass)
{
$aNameSpec = self::GetNameSpec($sClass);
$aAttributes = $aNameSpec[1];
return $aAttributes;
}
/**
* @param string $sClass
*
@@ -5034,6 +5048,7 @@ abstract class MetaModel
// Check that any defined field exists
//
$aTableInfo['Fields'][$sKeyField]['used'] = true;
$aFriendlynameAttcodes = self::GetFriendlyNameAttributeCodeList($sClass);
foreach(self::ListAttributeDefs($sClass) as $sAttCode => $oAttDef)
{
if (!$oAttDef->CopyOnAllTables())
@@ -5050,6 +5065,14 @@ abstract class MetaModel
$aTableInfo['Fields'][$sField]['used'] = true;
$bIndexNeeded = $oAttDef->RequiresIndex();
if (!$bIndexNeeded)
{
// Add an index on the columns of the friendlyname
if (in_array($sField, $aFriendlynameAttcodes))
{
$bIndexNeeded = true;
}
}
$sFieldDefinition = "`$sField` $sDBFieldSpec";
if (!CMDBSource::IsField($sTable, $sField))