Eventlog query now uses event_id as already indexed #2437

Merged
merged 1 commit into from Nov 17, 2015

Projects

None yet

4 participants

@laf
Member
laf commented Nov 16, 2015

Fix #2435

event_id is already indexed:

PRIMARY KEY (event_id),

mysql> EXPLAIN SELECT COUNT(DATETIME) FROM eventlog AS E LEFT JOIN devices AS D ON E.host=D.device_id;
+----+-------------+-------+--------+---------------+---------+---------+-----------------+------+-------------+
| id | select_type | table | type   | possible_keys | key     | key_len | ref             | rows | Extra       |
+----+-------------+-------+--------+---------------+---------+---------+-----------------+------+-------------+
|  1 | SIMPLE      | E     | ALL    | NULL          | NULL    | NULL    | NULL            |   72 |             |
|  1 | SIMPLE      | D     | eq_ref | PRIMARY       | PRIMARY | 4       | librenms.E.host |    1 | Using index |
+----+-------------+-------+--------+---------------+---------+---------+-----------------+------+-------------+

to

mysql> EXPLAIN SELECT COUNT(event_id) FROM eventlog AS E LEFT JOIN devices AS D ON E.host=D.device_id;
+----+-------------+-------+--------+---------------+---------+---------+-----------------+------+-------------+
| id | select_type | table | type   | possible_keys | key     | key_len | ref             | rows | Extra       |
+----+-------------+-------+--------+---------------+---------+---------+-----------------+------+-------------+
|  1 | SIMPLE      | E     | index  | NULL          | host    | 4       | NULL            |   72 | Using index |
|  1 | SIMPLE      | D     | eq_ref | PRIMARY       | PRIMARY | 4       | librenms.E.host |    1 | Using index |
+----+-------------+-------+--------+---------------+---------+---------+-----------------+------+-------------+
@laf laf Eventlog query now uses event_id as already indexed
dce37d2
@laf laf added Bug WebUI labels Nov 16, 2015
@masonke
masonke commented Nov 16, 2015

Out of curiosity, what does this query do?
~KEM

@laf
Member
laf commented Nov 16, 2015

Gives us the total amount of eventlog items, it's needed to support pagination for the eventlog page.

@SaaldjorMike SaaldjorMike merged commit 886f711 into librenms:master Nov 17, 2015

2 checks passed

Auto-Deploy Build finished. No test results found.
Details
Scrutinizer No new issues
Details
@laf laf deleted the laf:issue-2435 branch Nov 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment