[ZBX-5514] More simple query for get_min_itemclock_by_itemid function Created: 2012 Aug 30  Updated: 2017 May 30  Resolved: 2012 Sep 05

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

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

Issue Links:
Duplicate

 Description   

In last sql query we use select for multiple itemids and then we calculate min clock for specified itemids.
We can simplify query - use MIN(clock) and select min clock at once.

For example:
Index: graphs.inc.php
===================================================================
— graphs.inc.php (revision 29944)
+++ graphs.inc.php (working copy)
@@ -266,10 +266,9 @@
}

$res = DBselect(

  • 'SELECT ht.itemid,MIN(ht.clock) AS min_clock'.
    + 'SELECT MIN(ht.clock) AS min_clock'.
    ' FROM '.$sql_from.' ht'.
  • ' WHERE '.DBcondition('ht.itemid', $itemids).
  • ' GROUP BY ht.itemid'
    + ' WHERE '.DBcondition('ht.itemid', $itemids)
    );
    while ($min_tmp = DBfetch($res)) {
    $min = (is_null($min)) ? $min_tmp['min_clock'] : min($min, $min_tmp['min_clock']);


 Comments   
Comment by Eduards Samersovs (Inactive) [ 2012 Sep 04 ]

Fixed in development branch svn://svn.zabbix.com/branches/dev/ZBX-5514
Tested in Mysql, Postgresql and Oracle.

Comment by richlv [ 2012 Sep 04 ]

i assume this will improve performance somewhere ? which user visible pages exactly would benefit from this ?

<Eduard> Screens, Host screens, Graphs pages now must work a little bit faster..

Comment by Eduards Samersovs (Inactive) [ 2012 Sep 04 ]

Fixed in versions pre-2.1.0 (beta) r30090, pre-2.0.3 r30089

Comment by Alexey Pustovalov [ 2012 Sep 04 ]

Please make this changes in 1.8 too.

<Eduard> FIXED

Comment by Eduards Samersovs (Inactive) [ 2012 Sep 05 ]

Fixed also in pre-1.8.16rc1 r30102

Generated at Fri Apr 19 21:39:39 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.