Simon Willison has written about using SQLite for a "Baked in data" architecture which is a super interesting method for some situations: https://simonwillison.net/2021/Jul/28/baked-data/ As he notes https://www.mozilla.org/ uses this pattern: > They started using SQLite back in 2018 in a system they call Bedrock ... Their site content lives in a ~22MB SQLite database file, which is built and uploaded to S3 and then…
I designed something that used a local SQLite database on the client and a remote postgresql instance as the master. It used read and write queues at each end for sync and was eventually consistent. Unfortunately it was far too advanced for the org and no one else understood it so it was canned in favour of a connected solution under the guise of ubiquitous internet access being available. This is proving to be a poo…
Ask HN: Have you used SQLite as a primary database?
321–330 of 330 posts
Re: Ask HN: Have you used SQLite as a primary database?
#322Earlier quoted context omitted.
I love watching people use "x per month" as some sort of architecture selection argument, especially when these arguments conclude in a proud justification of cloud sprawl. There are single node/CPU solutions that can process 10-100 million business events per second . I am almost certain that no one logged into HN right now has a realistic business case on their plate that would ever come close to exceeding that cap…
ESAIDBUSINESSTOOMANYTIMES
Re: Ask HN: Have you used SQLite as a primary database?
#323Earlier quoted context omitted.
That's not a risk, that's just an inefficiency further down the line (migrating data from sqlite to a "real" database can indeed be quite a chore, but far less so if you formalized your schema and constraints beforehand, so that a migration mostly involves exporting to SQL, rewriting where needed, and then importing into whatever dbms you end up using later on in the lifetime of your project). When we're talking abou…
Inefficiency or not, if you start down the path of SQLite, you need to invest good amount of time refactoring into another DB if you feel like migrating away. When I realized SQLite would store any type of data in any kind of column type, it was obvious SQLite is different from others. They only added strict types about a year ago but scared me enough not to use it. And how is SQLite any less secure? You can flat out…
Yes, plenty of folks just go for SQLite blindly, but the consequences of that aren't SQLite's doing: if you take the time to read through https://www.sqlite.org/features.html because you want to know what it can actually do, you'll almost certainly click through to https://www.sqlite.org/omitted.html because you'll want to know what it doesn't do, and then you'll see the "See also the Quirks, Caveats, and Gotchas of SQLite." link and you're going to follow it an read through https://www.sqlite.org/quirks.html because those sound pretty important to know about before you commit to using something that is going to be your application/service data store for the foreseeable future.
Re: Ask HN: Have you used SQLite as a primary database?
#324Earlier quoted context omitted.
ESAIDBUSINESSTOOMANYTIMES
Then replace business with the problem you're trying to solve, the good you're trying to do for your users, etc. Keeping the big picture in view doesn't have to mean you're only interested in making money.
Re: Ask HN: Have you used SQLite as a primary database?
#325Earlier quoted context omitted.
I just make key-value store tables and write a small interface to simplify access in H2 or SQLite.
But why not just use Redis (which is almost surely faster even vs. SQLite in-memory) instead of creating key-value tables?
Re: Ask HN: Have you used SQLite as a primary database?
#326I’ve worked on several projects with sqlite, both read and write heavy, all with high concurrency, with databases in the few hundred MB with 400k server clients, and 100 bare-metal servers running at capacity. The sqlite part of our system is never the problem. In our case sqlite has been an alternative to custom files on disk or replacing a spaghetti of hashmaps in memory. we also replaced a single postgresql instan…
For example, Linux limits the number of file descriptors to 1024 per process to each process can open up to 1024 files at any point in time.
I ran into this problem in the past in another project (the system ran out of file descriptors for another reason).
Re: Ask HN: Have you used SQLite as a primary database?
#327I use it together with Rails and the horizontal sharding feature. Each customer has it's own sqlite database running in WAL mode. Since the app is internally used, traffic/writes are pretty predictable. I also do backups periodically with ActiveJob using `.backup` on the sqlite3 client. It's simple and nice because I just have to worry about running the app, and nothing else.
Did you ever run into this problem?
Re: Ask HN: Have you used SQLite as a primary database?
#328Re: Ask HN: Have you used SQLite as a primary database?
#329Earlier quoted context omitted.
This was so inspiring to read. It's a very balanced take about the pros and cons of using SQLite vs. Postgres at scale. I say "inspiring" because using SQLite reminds me of the simplicity and productivity from coding for the "early web" that lost 10-15 years ago. The days when you could spin up a website without worrying about a bunch of ancillary services and focus on the app itself. For me, SQLite's lack of online…
I have this beef too. Tooling for dumping and restoring into a new schema are easy/simple/fast. So, these schema migrations can happen w/o issue. Some tricks with the PRAGMA directive in SQLite so you can roll out changes (eg: code supports old/new schema while migrating)
Our experience is SQLite is OK for small to medium projects, but when the business logic/data model becomes more complex, SQLite is not sufficient.
More discussions are captured here https://news.ycombinator.com/item?id=31038614
Re: Ask HN: Have you used SQLite as a primary database?
#330Since every user has a separate DB file, writes to those files don't block reads from the global DB file which contains everyones public data. As long as you keep your user DB schema the same as the global DB schema, it's pretty easy to sync records using a simple cron job.
More info on my tech stack here: https://withoutdistractions.com/cv/faq#technology
In case that link ever goes down, here's an archive link: https://web.archive.org/web/20220503102946/https://withoutdi...