3 ms·
SQLite isn't single threaded - and it can support multiple readers very well. The limitation with SQLite is that it doesn't support concurrent writes well - it
by simonw 6y ago
SQLite isn't single threaded - and it can support multiple readers very well.
The limitation with SQLite is that it doesn't support concurrent writes well - it needs to take a lock on the entire database to perform a write.
Writes are crazy fast (a few ms) so this often isn't a problem - but it does mean you wouldn't want to use it to build a site that has many people writing at once, like Hacker News for example.
For a site that has low (or no) writes, SQLite works really well even at a much larger scale - 100s of requests a second.
- the_duke 6y agoEnabling the write ahead log makes sqlite behaviour much, much better under (write) contention: > PRAGMA journal_mode=WAL;
- simonw 6y agoYeah I was getting occasional "database is locked" read errors on a project that had crons writing to the SQLite file which I solved by switching on WAL mode. It still doesn't let you have concurrent writes but it does mean that reads won't error if a write is going on at the same time.