Currently when a job is deleted we remove all the logs from disk, and also remove the corresponding log_* rows from the database. We should also delete the recipe_task_result rows for the deleted job. That table is by far our largest, which means it is always the most expensive one to ALTER TABLE. Anything we can do to reduce its size will be useful. (Slightly related to bug 1314271 which is about showing something sensible in the UI when looking at a deleted job or recipe.)
We may need to do this for 23.0... The patch for Installing status <http://gerrit.beaker-project.org/4797> includes an ALTER TABLE recipe_task_result, which is basically a worst case scenario for our upgrade. I think the last one of these we had took 8 hours. We are up to > 37 million rows in that table now.
(In reply to Dan Callaghan from comment #1) Ignore this comment. That patch is doing ALTER TABLE recipe_task, not recipe_task_result which is the table we are concerned with in this bug. So implementing this won't do anything to help the very high cost of that migration.
On Gerrit: gerrit.beaker-project.org/4805
Beaker 23.0 has been released.