Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why deleted_at?

We have soft_deleted as boolean which excludes data from all queries and last_updated which a particular query can use if it needs to.

If over 50% of your data is soft deleted then it's more like historical data for archiving purposes and yes, you need to move it somewhere else. But then maybe you shouldn't use soft delete for it but a separate "archive" procedure?





Are you asking why we wouldn’t use 'last_updated' to store when the record was deleted?

One reason is that you might want to know when it was last updated before it was deleted.


No, more like why you'd use a more expensive filter to hide soft deleted data, instead of just a flag.

Checking whether `deleted_at is null` should be extremely cheap, and it avoids the duplication and desynchronisation of having both “deleted” and “deleted_at”.

Yes, if your database has null. I know this is about postgres, but a lot of stuff is nosql now.

Even in MongoDB, you can can index `null` values, so I don't understand in what database system this would be a problem.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: