From c0552b092af0318f3dd99e6e1c674a6bc22b5474 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 16 Jun 2015 08:11:54 +0200 Subject: [PATCH] ServicedowntimestarthistoryQuery: Improve JOIN performance refs #9009 --- .../ServicedowntimestarthistoryQuery.php | 26 +++---------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimestarthistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimestarthistoryQuery.php index 7b1f1989a..b60d13d5d 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimestarthistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimestarthistoryQuery.php @@ -76,14 +76,8 @@ class ServicedowntimestarthistoryQuery extends IdoQuery array() )->join( array('so' => $this->prefix . 'objects'), - 'so.object_id = sdh.object_id', + 'so.object_id = sdh.object_id AND so.is_active = 1 AND so.objecttype_id = 2', array() - )->where( - 'so.is_active = ?', - 1 - )->where( - 'so.objecttype_id = ?', - 2 ); if (@func_get_arg(0) === false) { @@ -112,15 +106,8 @@ class ServicedowntimestarthistoryQuery 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 ); $this->select->group(array('sdh.downtimehistory_id', 'so.name1', 'so.name2')); } @@ -153,15 +140,8 @@ class ServicedowntimestarthistoryQuery 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 ); $this->select->group(array('sdh.downtimehistory_id', 'so.name1', 'so.name2')); }