> PostgreSQL has a single master and multiple read replicas, Elasticsearch has horizontal scalability via sharding.
> if you have a large data set search and search relevancy is critical to your application (for example, in e-commerce), using a dedicated search engine like Elasticsearch is going to perform better
I love the mentality of "default to using Postgres for everything, and specialize when you need to." In this case, it looks like you'll need to evolve text search out of Postgres the moment your dataset gets into the millions, which roughly matches my experience.
So I'm not sure at what point Postgres will start to be limited on this front but it's definitely a different order of magnitude, unless it's a wildly different workload than my team has.
Happy to answer any questions. As with any DB comparison, it's tricky and I might have errors or I might have missed obvious things.
1. In the same document (a document in ES is a JSON object) 2. You have indices for them. ES (and Lucene) supports indices on raw text values and numbers as well.
ES does not do well with relations (joins). You can de-normalize data to deal with that.. but that makes data consistency harder.
Here [1] is an article that shows how to do that with the modern Postgres extension pgvector [2].
The downside is the reliance on a ML model to generate the embeddings, either from OpenAI as mentioned in the article from Supabase, or from an open-source library.
[1] https://supabase.com/blog/openai-embeddings-postgres-vector [2] https://github.com/pgvector/pgvector
So there are some workloads that are small enough you can use a different an alternate to Elasticsearch (and where performance is not paramount), and other workloads that are sort of too big for Elasticsearch (and where performance is paramount).
I'm not calling out Elastic or Google Cloud BigTable per se. For their core features, and their design-for-purpose both are wonderful products. They just weren't designed for real-time OLAP.
The same with Postgres. Or MongoDB. It tends to happen that we take what we know and we throw it at whatever the problem-of-the-day happens to be.
Over time, we discover design-for-purpose solutions and move appropriate use cases to it.
https://github.com/matthewfranglen/postgres-elasticsearch-fd...