From 326013428eebd168c6394933b08c7825944958ff Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 16 Jun 2015 08:10:55 +0200 Subject: [PATCH] HostnotificationQuery: Improve JOIN performance refs #9009 --- .../Ido/Query/HostnotificationQuery.php | 35 +++---------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostnotificationQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostnotificationQuery.php index 12b4715c7..d4dea4ae1 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostnotificationQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostnotificationQuery.php @@ -112,14 +112,8 @@ class HostnotificationQuery extends IdoQuery array() )->join( array('ho' => $this->prefix . 'objects'), - 'ho.object_id = hn.object_id', + 'ho.object_id = hn.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['notifications'] = true; } @@ -178,15 +172,8 @@ class HostnotificationQuery extends IdoQuery 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 ); if (! $this->hasJoinedVirtualTable('contactnotifications') && !$this->hasJoinedVirtualTable('history')) { @@ -222,15 +209,8 @@ class HostnotificationQuery extends IdoQuery 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 ); } @@ -245,15 +225,8 @@ class HostnotificationQuery extends IdoQuery 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 ); if (! $this->hasJoinedVirtualTable('contactnotifications') && !$this->hasJoinedVirtualTable('history')) {