July 9th, 2024

Just Use Postgres for Everything

The blog post advocates for using PostgreSQL extensively in tech stacks to simplify development, improve productivity, and reduce complexity. It highlights benefits like scalability, efficiency, and cost-effectiveness, promoting a consolidated approach.

Read original articleLink Icon
Just Use Postgres for Everything

In a blog post titled "Just Use Postgres for Everything," the author advocates for simplifying tech stacks by relying solely on PostgreSQL for various backend functionalities. By leveraging Postgres for tasks like caching, message queuing, data warehousing, geospatial queries, full-text search, and more, developers can streamline development, reduce complexity, and enhance productivity. The post suggests using Postgres in place of technologies like Redis, Kafka, Mongo, and Elastic, highlighting its versatility and efficiency. The author emphasizes the benefits of consolidating on Postgres, such as easier scalability, reduced cognitive load, and increased feature output without added costs. By adopting a "Postgres for everything" approach, startups can optimize their resources, focus on value-added tasks, and improve overall operational efficiency. The post also teases an upcoming book on technical debt and offers additional insights on CTO-related topics.

Related

Automatically setup pgAdmin with a Docker database

Automatically setup pgAdmin with a Docker database

Developer experience is enhanced by configuring a PostgreSQL local environment with Docker Compose. Defining variables and leveraging folders streamlines setup. Integrating pgAdmin automates connections, improving efficiency and simplifying future deployments.

Supabase (YC S20) Is Hiring Postgres SREs

Supabase (YC S20) Is Hiring Postgres SREs

Supabase seeks a Site Reliability Engineer to manage Postgres databases remotely. Responsibilities include enhancing reliability, ensuring high availability, and optimizing performance. Ideal candidates possess multi-tenant database experience, Postgres tools proficiency, and AWS deployment skills. Benefits include remote work, equity, health coverage, and tech allowance.

Using short lived Postgres servers for testing

Using short lived Postgres servers for testing

Database servers like PostgreSQL can be quickly set up for short-lived environments or CI/CD pipelines by creating new data directories and using pg_basebackup for efficient data population. This method simplifies testing and demo setups.

Just Use Postgres for Everything

Just Use Postgres for Everything

The article promotes using Postgres extensively in tech stacks to simplify development, improve scalability, and reduce operational complexity. By replacing various technologies with Postgres, developers can enhance productivity, focus on customer value, and potentially cut costs.

Mongo but on Postgres and with strong consistency benefits

Mongo but on Postgres and with strong consistency benefits

The Pongo project on GitHub offers a tool for utilizing MongoDB-like syntax on Postgres with strong consistency benefits. It supports data operations in Postgres and provides a MongoDB-compatible shim. Visit the GitHub repository for details.

Link Icon 12 comments
By @cultofmetatron - 5 months
A lot of points made here is also is why I believe Phoenix framework is the BEST stack for building mvps in 2024.

1. you get concurrency and pubsub built in with no external dependancies.

2. postgres suppport out of the box. our entire deployment is just phoenix + postgres

3. creating a microservice is easy. create a genserver, add it to your application.ex -> DONE. no need to create a seperate repo. its already able to send and receieve messages from other parts of your monolith using the built in pubsub system

4. Oban, the background worker library uses postgres.

end result is that as a small team, we are able to knock out a lot of features and scale it without any of the complexity most startups have. Its been 4 years and only now we are starting to consider bringing in an external message queue.

By @lucianbr - 5 months
As always, "it depends". There are situations where you can use Postgres as a queue perfectly fine. But there is no way Postgres can do as well or better than RabbitMQ in all situations. Same for text search, and so on.
By @zer00eyz - 5 months
I mostly agree with this...

> Use Postgres for Fulltext Search instead of Elastic.

Yea, that's not quite the same. Im going to make the argument that a well tuned search platform along side your data storage is probably one of the most useful things you can have. It's one of the first places where you will be "let down" by the Postgres solution.

As a document store, a queue, Postgres will do the job up to a point. When and where it breaks down in one of these ancillary roles you're likely to have the resource to support more systems, or a more "focused" tool.

By @dhbradshaw - 5 months
I've found this bias to be useful with two main exceptions:

1. It's nice if you can avoid using Postgres to store large files. 2. It's nice if you can avoid using Postgres for an event stream with massive volume (say billions of records per month that must be maintained and queried).

Postgres will work for either of these, but there are real advantages that come if you can keep your database lighter than these allow for.

By @arp242 - 5 months
Just use Postgres for everything - https://news.ycombinator.com/item?id=33934139 - Dec 2022 (431 comments)
By @lucianbr - 5 months
> Use Postgres for caching instead of Redis with UNLOGGED tables

This is not the same thing, is it? Redis is in-memory, while the Postgres tables will be on disk, even UNLOGGED.

By @jdboyd - 5 months
My leading use for redis on a system where I am already using Postgres is to use Celery. I suspect this is just one of many cases where people add an additional datastore because their frameworks and/or libraries make it easier to to that than to use Postgres for that type of data.
By @anacrolix - 5 months
Can you use a ton of extensions with a managed Postgres, or should you just host it yourself?
By @wavemode - 5 months
All of these points are valid, when given a caveat of "if Postgres covers your actual needs".

Like, I've personally worked on many systems that used Redis for absolutely no reason. As it was not actually measurably improving the latency of any part of the system. It was basically just another place to store data.

Obviously, Postgres and Redis are not the same, and there are situations where keeping data in memory at all times is important for latency. Hence the caveat. But most companies are not in any such situation.

Same story with the rest of these technologies - people often reach for them without really considering whether they are any sort of improvement over just storing the data in a relational database. This is commonly done by engineers who underestimate the capabilities of a relational database.

By @webprofusion - 5 months
Sure, but I need it embedded (so my app controls the installed version it needs).
By @up2isomorphism - 5 months
“AmazingCTO” and “just using xxx for everything” surely fit each other .