Project

General

Profile

Actions

Bug #23663

closed

Reports expiry task does a full table scan

Added by Jarryd Beck over 6 years ago. Updated about 5 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

Running foreman-rake reports:expire days=1 does a full table scan:

mysql> explain DELETE FROM `reports` WHERE `reports`.`type` IN ('ConfigReport') AND (reports.created_at < '2018-05-17 10:25:58');
+----+-------------+---------+------------+------+---------------------------------------------------------+------+---------+------+--------+----------+-------------+
| id | select_type | table   | partitions | type | possible_keys                                           | key  | key_len | ref  | rows   | filtered | Extra       |
+----+-------------+---------+------------+------+---------------------------------------------------------+------+---------+------+--------+----------+-------------+
|  1 | DELETE      | reports | NULL       | ALL  | index_reports_on_type,index_reports_on_type_and_host_id | NULL | NULL    | NULL | 573019 |   100.00 | Using where |
+----+-------------+---------+------------+------+---------------------------------------------------------+------+---------+------+--------+----------+-------------+
Actions

Also available in: Atom PDF