[ZBX-13338] CLONE - Slow Housekeeping of events Created: 2018 Jan 15  Updated: 2018 Jan 16  Resolved: 2018 Jan 16

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: None
Fix Version/s: None

Type: Problem report Priority: Critical
Reporter: Don Pobre Assignee: Unassigned
Resolution: Unsupported version Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates ZBX-13275 Slow Housekeeping of events Closed
Sprint: Sprint 24
Story Points: 1

 Description   

Housekeeping of events is too slow on MySQL because it's not using index provided, the query is:

select min(clock) from events where events.source=3 and events.object=0 and not exists (select null from problem where events.eventid=problem.eventid or events.eventid=problem.r_eventid)

MySQL is "Ver 14.14 Distrib 5.7.20, for Linux (x86_64) using EditLine wrapper", running on Ubuntu 16.04.

mysql> explain select min(clock) from events where events.source=3 and events.object=0 and not exists (select null from problem where events.eventid=problem.eventid or events.eventid=problem.r_eventid)\G
*************************** 1. row ***************************
           id: 1
  select_type: PRIMARY
        table: events
   partitions: NULL
         type: ref
possible_keys: events_1,events_2
          key: events_2
      key_len: 8
          ref: const,const
         rows: 15964577
     filtered: 100.00
        Extra: Using where; Using index
*************************** 2. row ***************************
           id: 2
  select_type: DEPENDENT SUBQUERY
        table: problem
   partitions: NULL
         type: ALL
possible_keys: PRIMARY,c_problem_2
          key: NULL
      key_len: NULL
          ref: NULL
         rows: 708846
     filtered: 19.00
        Extra: Range checked for each record (index map: 0x9)
2 rows in set, 3 warnings (0,00 sec)

It should be changed to:

mysql> explain select min(clock) from events where events.source=3 and events.object=0 and not exists (select null from problem where events.eventid=problem.eventid) and not exists (select null from problem where events.eventid=problem.r_eventid)\G
*************************** 1. row ***************************
           id: 1
  select_type: PRIMARY
        table: events
   partitions: NULL
         type: ref
possible_keys: events_1,events_2
          key: events_2
      key_len: 8
          ref: const,const
         rows: 15973658
     filtered: 100.00
        Extra: Using where; Using index
*************************** 2. row ***************************
           id: 3
  select_type: DEPENDENT SUBQUERY
        table: problem
   partitions: NULL
         type: ref
possible_keys: c_problem_2
          key: c_problem_2
      key_len: 9
          ref: zabbix.events.eventid
         rows: 1
     filtered: 100.00
        Extra: Using index
*************************** 3. row ***************************
           id: 2
  select_type: DEPENDENT SUBQUERY
        table: problem
   partitions: NULL
         type: eq_ref
possible_keys: PRIMARY
          key: PRIMARY
      key_len: 8
          ref: zabbix.events.eventid
         rows: 1
     filtered: 100.00
        Extra: Using index
3 rows in set, 3 warnings (0,00 sec)


 Comments   
Comment by Don Pobre [ 2018 Jan 15 ]

This is cloned from ZBX-13275. just upgraded from 3.2.10 to 3.2.11, looks like version 3.2.11 is also affected.

Comment by Don Pobre [ 2018 Jan 15 ]

duplicates to ZBX-13337

Comment by Vladislavs Sokurenko [ 2018 Jan 15 ]

could you please check if upgrading to 3.4.6 help?

Comment by Don Pobre [ 2018 Jan 16 ]

upgrading to 3.4.6 not an option for now. added index:

ALTER TABLE `events` DROP KEY `events_3`;

seems to fix the issue. correct me if im wrong with the resolution.

Thanks.

Comment by richlv [ 2018 Jan 16 ]

"affect version" of "4.0.0alpha1, 4.0 (plan)" might be wrong, the reporter seems to use 3.2

Comment by Glebs Ivanovskis (Inactive) [ 2018 Jan 16 ]

3.2 is probably affected but won't be fixed, because it is not supported any more. Consider upgrading.

Closing as Unsupported version.

Generated at Sat Mar 29 05:52:31 EET 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.