avrahamm's avatar

Big Job or several small jobs?

Hello! There are several tables in my DB rows quickly become irrelevant. Such as notifications, sent_sms_messages, sent_emails, probably failed_jobs, and some more. Let's assume I will delete all rows older than 60 days. I consider to create and schedule CleaningJob to run weekly or probably once in couple days. I see two options:

  1. To create one big cleaning job has several deleting queries.
  2. To create several, may be 5 small cleaning jobs with one query in each.

What's best?

0 likes
3 replies
Tray2's avatar

It depends like everything else but if they clean all the tables at the same interval it a single job should suffice.

1 like
the_zombiesplat's avatar
Level 1

Personally, I would write a single job if the tables depended on eachother. The reason there would be to avoid having orphaned records. Otherwise if they don't depend on eachother, then single jobs for the sake of separation of concerns would make for a code base that is easier to maintain and navigate.

1 like
avrahamm's avatar

Thank you @tray2 and @the_zombiesplat It is about independent tables in my case. Also, I rethink if I run one big job it is more risk will run out of time and fail. It seems several small jobs approach is more suitable for my case.

Please or to participate in this conversation.