Index: branches/unlabeled/unlabeled-1.4.10/kernel/units/general/helpers/multilanguage.php =================================================================== diff -u -N -r4360 -r5183 --- branches/unlabeled/unlabeled-1.4.10/kernel/units/general/helpers/multilanguage.php (.../multilanguage.php) (revision 4360) +++ branches/unlabeled/unlabeled-1.4.10/kernel/units/general/helpers/multilanguage.php (.../multilanguage.php) (revision 5183) @@ -179,8 +179,19 @@ */ function generateAlterSQL($field_mask, $start_index, $create_count) { - $i_count = $start_index + $create_count; + static $single_lang = null; + if (!isset($single_lang)) { + // if single language mode, then create indexes only on primary columns + $table_name = $this->Application->getUnitOption('lang', 'TableName'); + $sql = 'SELECT COUNT(*) + FROM '.$table_name.' + WHERE Enabled = 1'; + // if language count = 0, then assume it's multi language mode + $single_lang = $this->Conn->GetOne($sql) == 1; + } + $ret = ' '; + $i_count = $start_index + $create_count; while ($start_index < $i_count) { list($prev_field,$type) = explode(' ', sprintf($field_mask, $start_index - 1) ); if (substr($prev_field, 0, 3) == 'l0_') { @@ -198,8 +209,12 @@ $field_expression = sprintf($field_mask, $start_index); $ret .= 'ADD COLUMN '.$field_expression.' AFTER `'.$prev_field.'`, '; + if ($start_index == $this->Application->GetDefaultLanguageId() || !$single_lang) { + // create index for primary language column + for all others (if multiple languages installed) list($field_name, $field_params) = explode(' ', $field_expression, 2); $ret .= 'ADD INDEX (`'.$field_name.'` (5) ), '; + } + $start_index++; } return preg_replace('/, $/',';',$ret);