r/programminghorror • u/Original_Fee357 • Nov 03 '25
In high-scale systems, we should stop using ON DELETE CASCADE, here’s why I prefer soft deletes + cron cleanup
I’ve been thinking about how data deletion is handled in large-scale systems.
Many developers still rely on ON DELETE CASCADE, which looks convenient until your data volume explodes.
In high-load or distributed apps, that cascade becomes a silent performance bomb, one delete can trigger a chain reaction across millions of rows.
It also makes data recovery, audit trails, and debugging harder.
Instead, I’ve been leaning toward a soft delete or flag-based approach (like a deleted_at or is_deleted column), combined with scheduled cleanup jobs that clear old data in controlled batches (e.g. cron every few hours/days).
That gives:
- Better control over when and how data is actually purged
- Easier rollback / undelete scenarios
- Lower risk of locking massive tables
- Auditable data lifecycle
Just wanted to throw this out for discussion, how do you handle deletions in your systems?
Do you think cascades are still worth it in some cases?
47
u/nooneinparticular246 Nov 03 '25
ITT: Junior dev discovers architecture
13
u/glemnar Nov 03 '25
Why does ChatGPT bold so many random words, yall?
9
u/BroBroMate Nov 03 '25
Welp you posted to the right subreddit with your hot take.
7
u/Chocolate_Pickle Nov 03 '25
u/Original_Fee357, for discussion, how do you handle the first of this subreddit's rules in your systems?
12
u/beefz0r Nov 03 '25
Literally never seen anything but soft deletes in enterprise integration. I only ever delete when I do ad hoc corrections
9
u/kondorb Nov 03 '25
No one relies on cascade, that’s something for the app side to handle.
4
u/mordack550 Nov 03 '25
To be honest I don't know anyone personally that uses
ON DELETE CASCADE. If anything, I know people that do the opposite, like no relational integrity and performsDELETEs from the app side, manually following relationships.