4 ms·
Hi! The author here. I appreciate your reply here and in few other threads for this post too. I think they are very well thought out. I also like how it brewed
by shayonj 3y ago
Hi! The author here. I appreciate your reply here and in few other threads for this post too. I think they are very well thought out. I also like how it brewed more branches of other good discussions.
I totally agree that this decision isn't to be taken lightly. That said, I figured I'd also take this opportunity to clarify a few things:
- My post aims to prompt developers to critically assess whether the constraints they employ are truly essential or just conventionally used without question. They should weigh these constraints against the considerations mentioned in the post.
- While I recognize that lock contention is the database's way of managing application code, I propose that if foreign keys aren't necessary from the outset, then lock contention may only serve to impede performance. If you can rewrite your application code, say with `FOR UPDATE SKIP LOCKED`, great!
- I am also not recommending to drop all FK constraints, but to challenge and see if each one of them is necessary, and if it is, also good.
- As always, there is no solution fits all!