Description
Ruby on Rails is making many changes to improve SQLite support. Apparently, one of the most noticeable is using BEGIN IMMEDIATE TRANSACTION
. Quoting from this article from the author of such improvements for RoR (it is a highly recommended read for anyone using SQLite):
By default, SQLite uses a deferred transaction mode. This means that SQLite will not acquire the lock until a write operation is made inside the transaction.
In a context where you only have one connection or you have a large amount of transactions that only do read operations, this is great for performance, because it means that SQLite doesn’t have to acquire a lock on the database for every transaction, only for transactions that actually write to the database.
The he goes about how 99% of the time starting a transaction in Ruby on Rails means that there will be a database write. The conclusion is that immediate transactions should be the default for most cases.
This made me wonder a few things:
- Is it possible to use immediate transactions with Ecto?
- If not, would it be possible to add support for them? I could help if this feature seems interesting to have.
- Would it be interesting to replicate the RoR behaviour in Ecto as well and make immediate transactions the default? I've been thinking about it and the fact that most transactions result in a database write seems true in my experience.