Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Performance issue updating node last reports #277

Closed
sodabrew opened this issue Feb 25, 2014 · 1 comment
Closed

Performance issue updating node last reports #277

sodabrew opened this issue Feb 25, 2014 · 1 comment

Comments

@sodabrew
Copy link
Owner

This is well and truly bizarre and causes report pruning to take a very long time:

mysql> select * from reports where node_id = 2099 and kind = 'inspect' order by time desc;
Empty set (0.00 sec)

mysql> select * from reports where node_id = 2099 and kind = 'inspect' order by time desc limit 1;
Empty set (3.16 sec)

Ah, it's triggering MySQL to use the wrong index:

mysql> explain select * from reports where node_id = 2099 and kind = 'inspect' order by time desc;
+----+-------------+---------+------+--------------------------+--------------------------+---------+-------+------+-----------------------------+
| id | select_type | table   | type | possible_keys            | key                      | key_len | ref   | rows | Extra                       |
+----+-------------+---------+------+--------------------------+--------------------------+---------+-------+------+-----------------------------+
|  1 | SIMPLE      | reports | ref  | index_reports_on_node_id | index_reports_on_node_id | 5       | const | 1682 | Using where; Using filesort |
+----+-------------+---------+------+--------------------------+--------------------------+---------+-------+------+-----------------------------+
1 row in set (0.00 sec)

mysql> explain select * from reports where node_id = 2099 and kind = 'inspect' order by time desc limit 1;
+----+-------------+---------+-------+--------------------------+----------------------------------------------+---------+------+------+-------------+
| id | select_type | table   | type  | possible_keys            | key                                          | key_len | ref  | rows | Extra       |
+----+-------------+---------+-------+--------------------------+----------------------------------------------+---------+------+------+-------------+
|  1 | SIMPLE      | reports | index | index_reports_on_node_id | index_reports_on_time_and_node_id_and_status | 782     | NULL | 1073 | Using where |
+----+-------------+---------+-------+--------------------------+----------------------------------------------+---------+------+------+-------------+
1 row in set (0.00 sec)

(This is MySQL 5.5.35)

@bwitt
Copy link
Collaborator

bwitt commented Aug 25, 2018

I'm going to call this a bug in MySQL 5.5.35; please re-open if this is not the case!

@bwitt bwitt closed this as completed Aug 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants