ServicenotificationQuery: Improve JOIN performance

refs #9009
This commit is contained in:
Johannes Meyer 2015-06-16 08:12:08 +02:00
parent 8bf269c2b3
commit 7d9b09fdc8
1 changed files with 3 additions and 23 deletions

View File

@ -113,14 +113,8 @@ class ServicenotificationQuery extends IdoQuery
array() array()
)->join( )->join(
array('so' => $this->prefix . 'objects'), array('so' => $this->prefix . 'objects'),
'so.object_id = sn.object_id', 'so.object_id = sn.object_id AND so.is_active = 1 AND so.objecttype_id = 2',
array() array()
)->where(
'so.is_active = ?',
1
)->where(
'so.objecttype_id = ?',
2
); );
$this->joinedVirtualTables['notifications'] = true; $this->joinedVirtualTables['notifications'] = true;
} }
@ -180,15 +174,8 @@ class ServicenotificationQuery extends IdoQuery
array() array()
)->join( )->join(
array('hgo' => $this->prefix . 'objects'), 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() array()
)->where(
'hgo.is_active = ?',
1
)
->where(
'hgo.objecttype_id = ?',
3
); );
if (! $this->hasJoinedVirtualTable('contactnotifications') && !$this->hasJoinedVirtualTable('history')) { if (! $this->hasJoinedVirtualTable('contactnotifications') && !$this->hasJoinedVirtualTable('history')) {
@ -224,15 +211,8 @@ class ServicenotificationQuery extends IdoQuery
array() array()
)->join( )->join(
array('sgo' => $this->prefix . 'objects'), 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() array()
)->where(
'sgo.is_active = ?',
1
)
->where(
'sgo.objecttype_id = ?',
4
); );
if (! $this->hasJoinedVirtualTable('contactnotifications') && !$this->hasJoinedVirtualTable('history')) { if (! $this->hasJoinedVirtualTable('contactnotifications') && !$this->hasJoinedVirtualTable('history')) {