Partial indexes give you approximately the same speedup as deletes.
Partial indexes give you approximately the same speedup as deletes.
1. Row bloat.
2. Bad plan estimation due to bloat.
3. Needing filtered indexes for anything that's a row based unique constraint.
4. All history in one table means changing schemas is a PITA, and you're backfilling stuff that's not real.
5. There's more but that's just off the top.
2. Got a citation for that? Pretty sure #3 makes that not true, but I'm open to be educated.
3. Yes, and? You're going to have those indexes anyway. That's the point.
4. You don't have to have all rows in a single table just because you took delete out of any user-facing query logic.
5. I think you need some more examples.
Deleting rows should generally be via the same type of query patterns you use to find them, or that's pretty weird.
I think #4 is something that most people dont implement - ime they just tombstone in their own table, and then all of the other problems are pretty rampant.
Having separate indexes for deletes might be a thing, but taking a history of every change to a thing in a relational way is still a big pain because of the schema cost, merging changes in an audit table when its really a slowly changing dimension is really weird to most query patterns.
To #2 - it depends on your query engine, but if every query does have filtered indexes there's still a cost to having two tables in one table (ignoring #4)
Particularly in the case of growth oriented companies, if your user base is growing exponentially, then half of your records are less than a year old anyway. This bloat is not the problem you make it. And as I said elsewhere, a row that is tombstoned can be deleted offline at some cadence that doesn’t break your other workflows. For instance when nearly all of its siblings are also dead.
You can push on devs to fix things like pointless logical updates but its really easy to have a rogue process create copies of your entire dataset each time it runs.
There's always someone who is prepared to downvote, literally or figuratively, something that will eventually be the solution to some problem they created in production.
When I get downvoted for ideas and not demeanor, 2/3rds of the time it's just job security.
c.f. sibling comment written 10 minutes before yours, several trivial things.
More concretely from a downvoter: 1. I want _nothing_ to do with user data. Nothing. Toxic nuclear waste. The idea of keeping the waste on hand needs strong justification.
2. The idea of "just leave the rows but mark is_deleted" has a fundamental distate to a profession where O(n) is a constant worry.
3. The breezy way it dismisses this as an obvious solution that ~eveyone agrees suggets a small breadth of experience. That's not bad! But then we're at Chesterton's fence.
In summary, you can get downvoted for ruling out someone else's concrete lived experience, not just because your dangerous ideas threaten their paycheck (I don't even have a job!)
Additionally, with regulations like CCPA in some jurisdictions, this isn't even optional anymore. At some point you will need to hard delete user data.
Much of the user information we acquire is the result of greed, nosiness, or laziness. If deleting users is difficult for you, that’s an architectural problem that has next to nothing to do with my comment.
The world is absolutely full of rules that have exactly one exception. If they have two we apply the Rule of Three and either fix it or change it back to two. I have absolutely no qualms about treating user data as the exception here.
If you’re Amazon, you don’t even need much of the PII until checkout time. Collecting or looking up that data up early is a security risk. Checkouts are going to be orders of magnitude fewer operations than your browsing traffic. When the order of magnitude changes, the solutions often change. And lastly, checkouts are when you make money. Expensive operations, like inserting into a table with fragmentation problems, are much easier to justify when they are attached to revenue events.
An ad campaign that falls flat can bankrupt you. A fire or earthquake can bankrupt you. A fancy and unusable site relaunch can bankrupt you. Spending a little money at the point of sale cannot.
How do we solve X? You don't solve X, you solve Y. The XY problem, not Chesterton's Fence.
Not sure I follow you entirely on user data. There's user data that absolutely requires an audit trail, like subscriptions or orders. There's user data that might start out as null and eventually transition to an inane value, like avatar or self-description. You don't need complex merge rules for that data. It possibly only happens when their account is being hacked and that's not the data you need in that particular situation, yeah?
Under the hood most db's do this as well (vacuum, repair database, etc).
At this point I've learned this lesson the hard way enough that I'd need to hear some really good reasons to NOT do it this way.
One of the consensus algorithms Google was bragging about a few years back was built on very high precision hardware clocks that set a ridiculously short timeframe to achieve consensus on new data. After a few hundred milliseconds you could be certain a record had settled and make business decisions based off of it. It’s the same basic idea, but three orders of magnitude faster.
If your rows do age out at the same time, then I’d be tempted to ask you why you’re storing logs in a relational database, because that’s essentially what you have at that point.
Yes, pretty sure it’s very common. That doesn’t make it the greatest design, common doesn’t mean good.