3 ms·
But, if you want to ensure the data is never visible in an inconsistent state, you either need to use db-level concurrency-related features like transactions or
by jrochkind1 7y ago
But, if you want to ensure the data is never visible in an inconsistent state, you either need to use db-level concurrency-related features like transactions or locks; or some kind of lock or other concurrency-control features at the app level while guaranteeing the db has no clients other than your app.
It seems difficult to wind up with better performance characteristics by doing this than using the higher-level abstractions the database is already supplying for this purpose, like constraints. I suppose it's possible with enough hours by enough experts, as you suggest. I doubt that's what github actually did though, they probably instead decided to write app logic that was resilient to visible data inconsistency. Which sounds difficult and dangerous to me, but github is a pretty reliable app, so I guess something worked.
- recursive 7y agoTransactions are a pretty widely used RDBMS feature AFAIK.
- jrochkind1 7y agoRight, so are foreign key constraints. Ensuring foreign key consistency without foreign key constraints is not just "use transactions", you have to be careful and intentional about how you are using them (and ensure all clients do). Why would you choose this over just using the foreign key constraint which takes care of it for you, using the same underlying technology? Perhaps that's a clearer way to say what I was trying to say originally.