by degamad · 1y ago · 0 comments
If you need to scale writes.
I'd argue writes scale better wtih sqlite than postgresql.
Also I often need to read-after-write during the same request, using transactions.
And rails apps are often CRUDy.
Each batch item can be a combination of read/write/update that happen in sequence and therefore can give you the same semantics as a traditional transaction/rollback. eg:
- read -> Does the account have enough funds?
- write -> transfer 100$ from this user to another account
This is also much simpler to write than in other databases as you don't have to worry about n+1.
To go with your example, take something like
1) add $100 to this user's account 2) add $100 to the service fees account 3) deduct $101 from the other user's account to cover these
Must all happen or none.