Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-5514

More simple query for get_min_itemclock_by_itemid function

XMLWordPrintable

      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']);

            Unassigned Unassigned
            dotneft Alexey Pustovalov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: