Ad Widget

Collapse

Zabbix 1.5 - Invalid Query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Palmertree
    Senior Member
    • Sep 2005
    • 746

    #1

    Zabbix 1.5 - Invalid Query

    I am seeing this every second almost in my database logs:

    select g.groupid, g.name from groups g left join hosts_groups hg on g.groupid=hg.groupid and hg.hostid=100100000000171 where (g.groupid div 100000000000000) in (1) AND hg.hostid is NULL order by g.name,g.groupid;

    Looks invalid since you can not compare a hostid number and also look for only ones that are NULL.
  • Palmertree
    Senior Member
    • Sep 2005
    • 746

    #2
    mysql> explain select g.groupid, g.name from groups g left join hosts_groups hg on g.groupid=hg.groupid and hg.hostid=100100000000264 where (g.groupid div 100000000000000) in (1) AND hg.hostid is NULL order by g.name,g.groupid;

    +----+-------------+-------+-------+--------------------------------------+----------------+---------+------------------------+------+------------------------------------------+
    | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
    +----+-------------+-------+-------+--------------------------------------+----------------+---------+------------------------+------+------------------------------------------+
    | 1 | SIMPLE | g | index | NULL | groups_1 | 66 | NULL | 113 | Using where; Using index; Using filesort |
    | 1 | SIMPLE | hg | ref | hosts_groups_1,hosts_groups_2.custom | hosts_groups_1 | 16 | const,zabbix.g.groupid | 1 | Using where; Using index; Not exists |
    +----+-------------+-------+-------+--------------------------------------+----------------+---------+------------------------+------+------------------------------------------+
    2 rows in set

    Comment

    • Palmertree
      Senior Member
      • Sep 2005
      • 746

      #3
      Got rid of the NULL in the where cause and it looks like this:

      mysql> explain select g.groupid, g.name from groups g left join hosts_groups hg on g.groupid=hg.groupid and hg.hostid=100100000000264 where (g.groupid div 100000000000000) in (1)
      order by g.name,g.groupid;
      +----+-------------+-------+-------+--------------------------------------+----------------+---------+------------------------+------+------------------------------------------+
      | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
      +----+-------------+-------+-------+--------------------------------------+----------------+---------+------------------------+------+------------------------------------------+
      | 1 | SIMPLE | g | index | NULL | groups_1 | 66 | NULL | 113 | Using where; Using index; Using filesort |
      | 1 | SIMPLE | hg | ref | hosts_groups_1,hosts_groups_2.custom | hosts_groups_1 | 16 | const,zabbix.g.groupid | 1 | Using index |
      +----+-------------+-------+-------+--------------------------------------+----------------+---------+------------------------+------+------------------------------------------+
      2 rows in set


      Looks like it is in hosts.php around line 847.

      Comment

      • Palmertree
        Senior Member
        • Sep 2005
        • 746

        #4
        Never mind. I think that it is right. Looks like the group names that need to return are the ones that do not match up which the NULL statement does. Sorry for the post.

        Comment

        Working...