diff --git a/classes/db/DBMysql.class.php b/classes/db/DBMysql.class.php index e1e9485d3..5481e7dfc 100644 --- a/classes/db/DBMysql.class.php +++ b/classes/db/DBMysql.class.php @@ -472,6 +472,16 @@ if($output->list_count) return $this->_getNavigationData($table_list, $columns, $condition, $output); + // list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가 + if($output->order) { + foreach($output->order as $key => $val) { + $col = $val[0]; + if(!in_array($col, array('list_order','update_order'))) continue; + if($condition) $condition .= sprintf(' and %s < 0 ', $col); + else $condition = sprintf(' where %s < 0 ', $col); + } + } + $query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition); if(count($output->groups)) $query .= sprintf(' group by %s', implode(',',$output->groups)); @@ -521,6 +531,16 @@ if($page > $total_page) $page = $total_page; $start_count = ($page-1)*$list_count; + // list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가 + if($output->order) { + foreach($output->order as $key => $val) { + $col = $val[0]; + if(!in_array($col, array('list_order','update_order'))) continue; + if($condition) $condition .= sprintf(' and %s < 0 ', $col); + else $condition = sprintf(' where %s < 0 ', $col); + } + } + $query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition); if(count($output->groups)) $query .= sprintf(' group by %s', implode(',',$output->groups)); diff --git a/classes/db/DBMysql_innodb.class.php b/classes/db/DBMysql_innodb.class.php index dd194c883..31c14633d 100644 --- a/classes/db/DBMysql_innodb.class.php +++ b/classes/db/DBMysql_innodb.class.php @@ -483,6 +483,16 @@ if($output->list_count) return $this->_getNavigationData($table_list, $columns, $condition, $output); + // list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가 + if($output->order) { + foreach($output->order as $key => $val) { + $col = $val[0]; + if(!in_array($col, array('list_order','update_order'))) continue; + if($condition) $condition .= sprintf(' and %s < 0 ', $col); + else $condition = sprintf(' where %s < 0 ', $col); + } + } + $query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition); if(count($output->groups)) $query .= sprintf(' group by %s', implode(',',$output->groups)); @@ -532,6 +542,16 @@ if($page > $total_page) $page = $total_page; $start_count = ($page-1)*$list_count; + // list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가 + if($output->order) { + foreach($output->order as $key => $val) { + $col = $val[0]; + if(!in_array($col, array('list_order','update_order'))) continue; + if($condition) $condition .= sprintf(' and %s < 0 ', $col); + else $condition = sprintf(' where %s < 0 ', $col); + } + } + $query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition); if(count($output->groups)) $query .= sprintf(' group by %s', implode(',',$output->groups));