News for hackers. Stuff that matters.
Re:Scaling Databases at Activision [pdf] by Yoric on Friday April 21, 2023 @02:49PM (#35658252)
I guess you can use indices instead of foreign keys? And somehow implement all the `ON DELETE CASCADE` manually within any transaction that removes the original row? Not sure how it's "good" code but it could be faster.
Re:Scaling Databases at Activision [pdf] by DasIch on Friday April 21, 2023 @03:11PM (#35658580)
A foreign key doesn't necessarily imply an index. If you are using postgres, you would have to add an index in addition to the foreign key, if you want one.

On delete cascade, depending on how many rows it cascades to, can be problematic because it's a very long running blocking operation. That's something one might want to do as a background operation and in batches. Although that won't make it faster.

Re:Scaling Databases at Activision [pdf] by sroussey on Friday April 21, 2023 @03:42PM (#35658954)
Faster in aggregate throughput can often be different from faster for a specific operation.

Personally, I find delete on cascade dangerous. I mean, lots of fun for a pen tester, sure…

Re:Scaling Databases at Activision [pdf] by Yoric on Sunday April 23, 2023 @06:26AM (#35675007)
> Personally, I find delete on cascade dangerous. I mean, lots of fun for a pen tester, sure…

Intriguing. Can you tell me more?

Re:Scaling Databases at Activision [pdf] by Yoric on Sunday April 23, 2023 @06:26AM (#35675001)
> A foreign key doesn't necessarily imply an index. If you are using postgres, you would have to add an index in addition to the foreign key, if you want one.

Sure, I meant that an index in which the key is primary.

> On delete cascade, depending on how many rows it cascades to, can be problematic because it's a very long running blocking operation. That's something one might want to do as a background operation and in batches. Although that won't make it faster.

That can definitely be a problem (just like destructor deallocation stampedes in C++ or Rust). Still less risky than cascading manually and asynchronously, I suspect.