[ZBX-6014] get_accessible_triggers function is slow and should be removed Created: 2012 Dec 19  Updated: 2017 May 30  Resolved: 2013 Jan 22

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 2.0.5rc1, 2.1.0
Fix Version/s: 2.0.5rc1, 2.1.0

Type: Incident report Priority: Major
Reporter: Alexey Pustovalov Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: performance
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File remove_hard_function.patch    
Issue Links:
Duplicate

 Description   

Look attached patch and comment with examples.



 Comments   
Comment by Alexey Pustovalov [ 2012 Dec 19 ]

For example:
1. Configuration->IT Services:
new

******************** Script profiler ********************
Total time: 0.782046
Total SQL time: 0.161721
SQL count: 32 (selects: 20 | executes: 12)
Peak memory usage: 21.25M
Memory limit: 2048M

old

******************** Script profiler ********************
Total time: 13.9741
Total SQL time: 3.200553
SQL count: 38 (selects: 21 | executes: 17)
Peak memory usage: 27.5M
Memory limit: 2048M

2. Reports->Triggers top 100:
new

******************** Script profiler ********************
Total time: 1.370789
Total SQL time: 0.758528
SQL count: 37 (selects: 21 | executes: 16)
Peak memory usage: 19.5M
Memory limit: 2048M

old

******************** Script profiler ********************
Total time: 6.133935
Total SQL time: 4.016241
SQL count: 46 (selects: 22 | executes: 24)
Peak memory usage: 32.5M
Memory limit: 2048M

3.Dashboard widget (latest 20 issues) :
new

******************** Script profiler ********************
Total time: 1.808492
Total SQL time: 1.282632
SQL count: 350 (selects: 170 | executes: 180)
Peak memory usage: 20.5M
Memory limit: 2048M

old

******************** Script profiler ********************
Total time: 2.564104
Total SQL time: 1.716625
SQL count: 356 (selects: 172 | executes: 184)
Peak memory usage: 20.75M
Memory limit: 2048M

4.Screens (History of actions element) :
new

******************** Script profiler ********************
Total time: 0.173205
Total SQL time: 0.028643
SQL count: 60 (selects: 48 | executes: 12)
Peak memory usage: 16.25M
Memory limit: 2048M

old

******************** Script profiler ********************
Total time: 4.457842
Total SQL time: 2.720278
SQL count: 65 (selects: 49 | executes: 16)
Peak memory usage: 33.25M
Memory limit: 2048M

There are all places where the function is used.

Comment by Oleg Egorov (Inactive) [ 2012 Dec 21 ]

RESOLVED IN svn://svn.zabbix.com/branches/dev/ZBX-6014 r32288, r32352, r32387, r32398, r32399

Comment by Toms (Inactive) [ 2013 Jan 07 ]

(1) API::Service()->get() with 'selectTrigger' option shouldn't expand descriptions by default.

oleg.egorov FIXED IN r32539, r32552

tomtom CLOSED

Comment by Toms (Inactive) [ 2013 Jan 07 ]

Review my changes in r32515

oleg.egorov CLOSED

Comment by Toms (Inactive) [ 2013 Jan 08 ]

(2)

// if services with specific trigger IDs were requested, return only the ones accessible to the current user.
	if ($options['filter']['triggerid']) {
		$trg_count = API::Trigger()->get(array(
		'triggerids' => $options['filter']['triggerid'],
		'countOutput' => true
	));

	if (!$trg_count) {
		unset($options['filter']['triggerid']);
	}
}

This is wrong. Note that $options['filter']['triggerid'] can be an array of values.

oleg.egorov RESOLVED IN r32592

tomtom CLOSED

Comment by Toms (Inactive) [ 2013 Jan 08 ]

(3)
CService.php line:602 'SELECT sa.servicealarmid,sa.serviceid,sa.clock,sa.value'. should be * as it was before

oleg.egorov RESOLVED IN r32592

tomtom CLOSED

Comment by Toms (Inactive) [ 2013 Jan 08 ]

(4) unnecessary line $triggers = zbx_toHash(zbx_objectValues($services, 'trigger'), 'triggerid'); in srv_status.php line:144

oleg.egorov RESOLVED IN r32592

tomtom CLOSED

Comment by Toms (Inactive) [ 2013 Jan 08 ]

(5) Changes in CService.php from line:1655 unnecessary. You can just use DBfetch($res, false) with second parameter as false in line:84, to not convert null values to 0.

oleg.egorov RESOLVED IN r32592

tomtom CLOSED

jelisejev I'm afraid you can't use DBfetch($res, false), because then service.get will return NULLs instead of zeroes for services without triggers. REOPENED.

oleg.egorov RESOLVED IN r32639

jelisejev CLOSED.

Comment by Toms (Inactive) [ 2013 Jan 09 ]

TESTED

Comment by Oleg Egorov (Inactive) [ 2013 Jan 09 ]

FIXED FOR 2.0.5rc1 in r32629

Comment by Oleg Egorov (Inactive) [ 2013 Jan 10 ]

Created development branch for trunk version: svn://svn.zabbix.com/branches/dev/ZBX-6014-trunk

Comment by Pavels Jelisejevs (Inactive) [ 2013 Jan 10 ]

(6) Since you're going to fix (5) please also correct the following issues:

1. please revert the changes in CService.getSla(), parameters need to be normalized in the beginning of the method;
2. the SQL for checking permissions is repeated 3 times, it should be moved to a separate function;
3. selectTriggers in CService::addRelatedObjects() does't need to use the trigger API.

oleg.egorov RESOLVED IN r32639

jelisejev CLOSED.

Comment by Oleg Egorov (Inactive) [ 2013 Jan 10 ]

FIXED FOR 2.0.5rc1 in r32657

Comment by Oleg Egorov (Inactive) [ 2013 Jan 11 ]

FIXED FOR 2.1.0 IN svn://svn.zabbix.com/branches/dev/ZBX-6014-trunk r32677

Comment by Toms (Inactive) [ 2013 Jan 15 ]

(7) in services.php lines: 291, 331, 387
at these points CMacrosResolverHelper::resolveTriggerNames() should be used as analogue to CTriggerHelper::batchExpandDescription()

oleg.egorov RESOLVED r32822

Comment by Toms (Inactive) [ 2013 Jan 15 ]

(8) regarding changes in configuration.services.child.list.php
after removal of triggerid data, there is hidden input field with undefined data in service editing Dependencie tab:

<input type="hidden" value="undefined" name="children[7][triggerid]">

oleg.egorov RESOLVED r32822, r32834, r32838

tomtom CLOSED

Comment by Toms (Inactive) [ 2013 Jan 17 ]

TESTED

Comment by Alexey Pustovalov [ 2013 Jan 17 ]

Wow! Thank you both very much!!!

Comment by Oleg Egorov (Inactive) [ 2013 Jan 18 ]

FIXED IN 2.1.0(trunk) r32885
CLOSED

Comment by Pavels Jelisejevs (Inactive) [ 2013 Jan 18 ]

I've reverted some unnecessary changes to the trunk in r32895.

Comment by Eduards Samersovs (Inactive) [ 2013 Jan 22 ]

Tested

Comment by Oleg Egorov (Inactive) [ 2013 Jan 22 ]

FIXED IN 2.1.0(trunk) r33017

Generated at Sat Apr 20 03:57:13 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.