monitoring: Eliminate unncessary GROUP BY clauses in the HoststatusQuery
refs #9956
This commit is contained in:
parent
6e12dd4d78
commit
4ab20b9142
|
@ -242,62 +242,65 @@ class HoststatusQuery extends IdoQuery
|
||||||
*/
|
*/
|
||||||
public function getGroup()
|
public function getGroup()
|
||||||
{
|
{
|
||||||
$group = array();
|
$group = parent::getGroup() ?: array();
|
||||||
if ($this->hasJoinedVirtualTable('hostgroups') || $this->hasJoinedVirtualTable('services')) {
|
if (! is_array($group)) {
|
||||||
$group = array('h.host_id', 'ho.object_id');
|
$group = array($group);
|
||||||
if ($this->hasJoinedVirtualTable('hoststatus')) {
|
}
|
||||||
$group[] = 'hs.hoststatus_id';
|
$groupedTables = array();
|
||||||
}
|
if ($this->hasJoinedVirtualTable('servicegroups')) {
|
||||||
|
$serviceGroupColumns = array_keys($this->columnMap['servicegroups']);
|
||||||
if ($this->hasJoinedVirtualTable('serviceproblemsummary')) {
|
$selectedServiceGroupColumns = array_intersect($serviceGroupColumns, array_keys($this->columns));
|
||||||
$group[] = 'sps.unhandled_services_count';
|
if (! empty($selectedServiceGroupColumns)) {
|
||||||
}
|
$group[] = 'ho.object_id';
|
||||||
|
$group[] = 'h.host_id';
|
||||||
if ($this->hasJoinedVirtualTable('hostgroups')) {
|
$group[] = 'sgo.object_id';
|
||||||
$selected = false;
|
$group[] = 'sg.servicegroup_id';
|
||||||
foreach ($this->columns as $alias => $column) {
|
$groupedTables['hosts'] = true;
|
||||||
if ($column instanceof Zend_Db_Expr) {
|
$groupedTables['servicegroups'] = true;
|
||||||
continue;
|
}
|
||||||
}
|
}
|
||||||
|
if ($this->hasJoinedVirtualTable('hostgroups')) {
|
||||||
$table = $this->aliasToTableName(
|
$hostGroupColumns = array_keys($this->columnMap['hostgroups']);
|
||||||
$this->hasAliasName($alias) ? $alias : $this->customAliasToAlias($alias)
|
$selectedHostGroupColumns = array_intersect($hostGroupColumns, array_keys($this->columns));
|
||||||
);
|
if (! empty($selectedHostGroupColumns)) {
|
||||||
if ($table === 'hostgroups') {
|
if (! isset($groupedTables['hosts'])) {
|
||||||
$selected = true;
|
$group[] = 'ho.object_id';
|
||||||
break;
|
$group[] = 'h.host_id';
|
||||||
}
|
$groupedTables['hosts'] = true;
|
||||||
}
|
}
|
||||||
|
$group[] = 'hgo.object_id';
|
||||||
if ($selected) {
|
$group[] = 'hg.hostgroup_id';
|
||||||
$group[] = 'hg.hostgroup_id';
|
$groupedTables['hostgroups'] = true;
|
||||||
$group[] = 'hgo.object_id';
|
}
|
||||||
}
|
}
|
||||||
}
|
if (! empty($groupedTables)) {
|
||||||
|
foreach ($this->columns as $alias => $column) {
|
||||||
if ($this->hasJoinedVirtualTable('servicegroups')) {
|
if ($column instanceof Zend_Db_Expr || $column === '(NULL)') {
|
||||||
$selected = false;
|
continue;
|
||||||
foreach ($this->columns as $alias => $column) {
|
}
|
||||||
if ($column instanceof Zend_Db_Expr) {
|
$tableName = $this->aliasToTableName(
|
||||||
continue;
|
$this->hasAliasName($alias) ? $alias : $this->customAliasToAlias($alias)
|
||||||
}
|
);
|
||||||
|
if (isset($groupedTables[$tableName])) {
|
||||||
$table = $this->aliasToTableName(
|
continue;
|
||||||
$this->hasAliasName($alias) ? $alias : $this->customAliasToAlias($alias)
|
}
|
||||||
);
|
switch ($tableName) {
|
||||||
if ($table === 'servicegroups') {
|
case 'hoststatus':
|
||||||
$selected = true;
|
$group[] = 'hs.hoststatus_id';
|
||||||
break;
|
break;
|
||||||
}
|
case 'serviceproblemsummary':
|
||||||
}
|
$group[] = 'sps.unhandled_services_count';
|
||||||
|
break;
|
||||||
if ($selected) {
|
case 'services':
|
||||||
$group[] = 'sg.servicegroup_id';
|
$group[] = 'so.object_id';
|
||||||
$group[] = 'sgo.object_id';
|
$group[] = 's.service_id';
|
||||||
}
|
break;
|
||||||
|
default:
|
||||||
|
continue 2;
|
||||||
|
}
|
||||||
|
$groupedTables[$tableName] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $group;
|
return $group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue