From 4c3592a82e01403270fea726b38cea4095b1509f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 16 Jun 2015 08:11:09 +0200 Subject: [PATCH] HoststatusQuery: Improve JOIN performance refs #9009 --- .../Backend/Ido/Query/HoststatusQuery.php | 39 +++---------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php index 72f336075..fd2cd77e6 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php @@ -194,18 +194,12 @@ SQL; protected function joinBaseTables() { $this->select->from( - array('ho' => $this->prefix . 'objects'), + array('h' => $this->prefix . 'hosts'), array() )->join( - array('h' => $this->prefix . 'hosts'), - 'h.host_object_id = ho.object_id', + array('ho' => $this->prefix . 'objects'), + 'ho.object_id = h.host_object_id AND ho.is_active = 1 AND ho.objecttype_id = 1', array() - )->where( - 'ho.is_active = ?', - 1 - )->where( - 'ho.objecttype_id = ?', - 1 ); $this->joinedVirtualTables['hosts'] = true; } @@ -225,15 +219,8 @@ SQL; array() )->join( array('hgo' => $this->prefix . 'objects'), - 'hgo.object_id = hg.hostgroup_object_id', + 'hgo.object_id = hg.hostgroup_object_id AND hgo.is_active = 1 AND hgo.objecttype_id = 3', array() - )->where( - 'hgo.is_active = ?', - 1 - ) - ->where( - 'hgo.objecttype_id = ?', - 3 ); $this->group('ho.name1'); } @@ -314,15 +301,8 @@ SQL; array() )->join( array('sgo' => $this->prefix . 'objects'), - 'sgo.object_id = sg.servicegroup_object_id', + 'sgo.object_id = sg.servicegroup_object_id AND sgo.is_active = 1 AND sgo.objecttype_id = 4', array() - )->where( - 'sgo.is_active = ?', - 1 - ) - ->where( - 'sgo.objecttype_id = ?', - 4 ); $this->group('ho.name1'); } @@ -339,15 +319,8 @@ SQL; array() )->join( array('so' => $this->prefix . 'objects'), - 'so.object_id = s.service_object_id', + 'so.object_id = s.service_object_id AND so.is_active = 1 AND so.objecttype_id = 2', array() - )->where( - 'so.is_active = ?', - 1 - ) - ->where( - 'so.objecttype_id = ?', - 2 ); $this->group('ho.name1'); }