mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 02:31:40 +09:00
Added index hints for SQL Server. Improvements to existing query hints for Mysql and Cubrid.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9481 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
eaa1a02adc
commit
3815aece09
19 changed files with 320 additions and 6 deletions
|
|
@ -30,6 +30,7 @@
|
|||
require(_XE_PATH_.'classes/db/queryparts/table/JoinTable.class.php');
|
||||
require(_XE_PATH_.'classes/db/queryparts/table/CubridTableWithHint.class.php');
|
||||
require(_XE_PATH_.'classes/db/queryparts/table/MysqlTableWithHint.class.php');
|
||||
require(_XE_PATH_.'classes/db/queryparts/table/MssqlTableWithHint.class.php');
|
||||
require(_XE_PATH_.'classes/db/queryparts/table/IndexHint.class.php');
|
||||
require(_XE_PATH_.'classes/db/queryparts/condition/ConditionGroup.class.php');
|
||||
require(_XE_PATH_.'classes/db/queryparts/condition/Condition.class.php');
|
||||
|
|
@ -566,8 +567,9 @@
|
|||
if(is_a($tableObject, 'CubridTableWithHint'))
|
||||
$index_hint_list .= $tableObject->getIndexHintString() . ', ';
|
||||
}
|
||||
$index_hint_list = substr($index_hint_list, 0, -2);
|
||||
if($index_hint_list != '')
|
||||
$index_hint_list = 'USING INDEX ' . substr($index_hint_list, 0, -2);
|
||||
$index_hint_list = 'USING INDEX ' . $index_hint_list;
|
||||
|
||||
$groupBy = $query->getGroupByString();
|
||||
if($groupBy != '') $groupBy = ' GROUP BY ' . $groupBy;
|
||||
|
|
|
|||
|
|
@ -12,9 +12,19 @@
|
|||
|
||||
function getIndexHintString(){
|
||||
$result = '';
|
||||
|
||||
// Retrieve table prefix, to add it to index name
|
||||
$db_info = Context::getDBInfo();
|
||||
$prefix = $db_info->master_db["db_table_prefix"];
|
||||
|
||||
foreach($this->index_hints_list as $index_hint){
|
||||
$result .= $this->alias . '.' . $index_hint->getIndexName()
|
||||
. ($index_hint->getIndexHintType() == 'FORCE' ? '(+)' : '') . ', ';
|
||||
$index_hint_type = $index_hint->getIndexHintType();
|
||||
if($index_hint_type !== 'IGNORE'){
|
||||
$result .= $this->alias . '.'
|
||||
. '"' . $prefix . substr($index_hint->getIndexName(), 1)
|
||||
. ($index_hint_type == 'FORCE' ? '(+)' : '')
|
||||
. ', ';
|
||||
}
|
||||
|
||||
}
|
||||
$result = substr($result, 0, -2);
|
||||
|
|
|
|||
29
classes/db/queryparts/table/MssqlTableWithHint.class.php
Normal file
29
classes/db/queryparts/table/MssqlTableWithHint.class.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
class MssqlTableWithHint extends Table {
|
||||
var $name;
|
||||
var $alias;
|
||||
var $index_hints_list;
|
||||
|
||||
function MssqlTableWithHint($name, $alias = NULL, $index_hints_list){
|
||||
parent::Table($name, $alias);
|
||||
$this->index_hints_list = $index_hints_list;
|
||||
}
|
||||
|
||||
function toString(){
|
||||
$result = parent::toString();
|
||||
|
||||
$index_hint_string = '';
|
||||
foreach($this->index_hints_list as $index_hint){
|
||||
$index_hint_type = $index_hint->getIndexHintType();
|
||||
if(in_array($index_hint_type, array('USE', 'FORCE')))
|
||||
$index_hint_string .= 'INDEX(' . $index_hint->getIndexName() . '), ';
|
||||
}
|
||||
if($index_hint_string != ''){
|
||||
$result .= ' WITH(' . substr($index_hint_string, 0, -2) . ') ';
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue