Video in progress

The product team is asking for complex analytical reports and full-text search in PostgreSQL. When is Postgres enough, and when do you add ClickHouse or Elasticsearch?

At moderate volume, Postgres's full-text search, pg_trgm, materialized views and reports on a replica are enough. If you need OLAP over billions of rows, or relevance and faceted search, use a dedicated system, but at the price of synchronization.

📖 Answer

I make this decision with three questions, not on whether I like the technology:

  1. The shape of the load. OLTP is many small queries touching a few rows by index. OLAP is few queries, but each one does a GROUP BY over 500 million rows. Row-oriented Postgres is slow at the second; columnar ClickHouse is 10-100 times faster for that job and compresses the data. On top of that, a heavy report takes over the OLTP database's cache and CPU.
  2. Volume and growth. With 50 million rows and a few reports a day, a replica + materialized view is enough. With billions of rows and real-time dashboards, a separate system.
  3. Search quality. Postgres tsvector is good for simple search, but for Uzbek/Russian morphology, typo tolerance, relevance tuning and faceted navigation, Elasticsearch/OpenSearch is strong.

If you add a new system, the price is:

  • Syncing the data: CDC (Debezium → Kafka → sink). Latency, and bugs like "why isn't it showing up in search".
  • Reindexing, schema evolution, separate monitoring and on-call knowledge.
  • The source of truth always stays Postgres: I design the search index so it can be rebuilt at any time.

The practical way: first do the best option inside Postgres and measure. When the numbers show we've hit the limit, I add the extra system and write the decision down as an ADR.