Menu

Post image 1
Post image 2
1 / 2
0

Designing for Soft Deletes: Patterns, Performance, and Queries

DEV Community·Alex Aslam·29 days ago
#TGNRAGBr
Reading 0:00
15s threshold

I still remember the exact moment I realized soft deletes weren't just a feature—they were a confession. We were seven months into a CRM project. The product manager came to my desk with a panicked look. "A user accidentally deleted 3,000 contact records. Can we get them back?" My stomach turned. I had designed the database with hard deletes—clean, efficient, and unforgiving. DELETE FROM contacts WHERE id = ? and it was gone. Forever. The backup restoration would take hours, and we'd lose a day's worth of new data. That night, as I wrote a painful data recovery script, I promised myself: never again. I joined the church of soft deletes. I added an is_deleted column to every table, updated all the queries, and felt a wave of relief. Then the performance problems started. Six months later, every query had WHERE deleted_at IS NULL , indexes were bloated, and a junior dev accidentally included soft‑deleted records in a report, causing chaos.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More