by andrewstuart · 3y ago · 0 comments
Postgres is good on multi core, incredibly feature rich, multi user, supported by everything, lightweight and has all the tools for production workload and management. All stuff that is important.
Most important difference to me being SQLite I understand lacks flexibility in modifying table structures.
This matters for cloud in that it means with Postgres you cannot take a "lots of small databases" strategy, e.g. database per user or database per document. You pretty much have to group a lot of data into one big database.
Many apps want to do that anyway! For them, Postgres makes sense. But in the growing world of global deployments and edge compute, the lots-of-small-databases approach is getting popular because it means you can store than data out on hundreds or thousands of edge locations, rather than a single central location. And many (not all) applications actually fit pretty well into a database-per-user or database-per-document model. Centralizing their storage only hurts performance for no benefit.
As a bonus, if you are able to run sqlite compiled directly into your app, not making any kind of network connection, it can be much faster than Postgres, especially in "N+1 select" situations (which are well-known to be a problem with most SQL databases, but are not a problem when using local sqlite). Postgres does not support running as a library like this.
You're right, it's a very interesting strategy. Unfortunately, last time I looked Cloudflare's D1 didn't support this approach as there was no API to create a database at runtime from Worker code. Has that changed?
From TFA:
> if you don’t need the Postgres features, they’re a liability. For example, even if you don’t use multiple user accounts, you’ll still need to configure and debug host-based authentication. You have to firewall off your Postgres server. And more features mean more documentation, which makes it difficult to understand the software you’re running. The documentation for Postgres 14 is nearly 3,000 pages.
Estimating the complexity of using a project can be really...complex. I think about systems I have used which make it easy to use a minimal set of features and where I don't have to reason about or be negatively impacted by aspects I do not benefit from, and other systems where things are less easily isolated and more challenging to reason about.
I do think the Postgres docs in particular seek to be a reference in addition to an operating manual and I for one really enjoy them. I think the point is well made that Postgres can be too much (or too much right now) for many projects.
False
>> you have to firewall off your server
Well yes. Are you saying SQLite servers don’t need a firewall?
>> more features/more documentation/hard to understand your software
Features lead to powerful software, documentation leads to understanding.
I'm not the author. But I can tell you there are no "SQLite servers". That's kind of the whole point.
For this case I guess they could try to bend sqlite to do this but the pain in doing so will probably not be worth the long term trouble than just using mysql or postgres or something like those.
I'm using sqlite in production for a backend service. There are plenty of downsides, but to focus on the positives:
- I can run all tests in a database in memory. It's incredibly fast to "spin up" and I can use a separate database per test
- Related, I find that I write more tests against the database instead of mocking a database, which cuts down on time writing tests.
- I don't need to start a database to run the backend
- I can have snapshots of the databases in a single files for various scenarios
All in all, the development process feels a lot faster. When something takes a millisecond instead of seconds, you do things differently.
Well, cost, right? Cost is a reason why someone may not want to use a traditional RDBMS. AWS RDS and GCP Cloud SQL aren't exactly the cheapest solutions out there.