Why Run Five Different Databases When PostgreSQL Already Does Almost Everything: JSONB, pgvector, Search, Metrics, and QueuesArticle · digest for November 21
Isometric 3D model of a powerful database server with extension slots and the blue PostgreSQL elephant
Article4 sections≈ 8 min

Why Run Five Different Databases When PostgreSQL Already Does Almost Everything: JSONB, pgvector, Search, Metrics, and Queues

When you start a new web project, it's tempting to build a "serious" stack. Unstructured JSON documents coming in? Spin up MongoDB. Need typo-tolerant search? Add Elasticsearch. Building an embedding-based RAG bot? Sign up for Pinecone. Collecting metrics? Deploy InfluxDB. Need background jobs? Bring in Redis.

On a Miro diagram, it looks solid. Every database was added for a real need. The bill comes due six months later in production. This approach is called Polyglot Persistence—choosing a separate database for each data type—and the biggest cost isn't your cloud invoice.

You pay in operational complexity. Every extra database means another connection pool, a separate backup routine, one more monitoring dashboard, a new way to break on Friday night, and another reason to wake up at 3 AM. A SQL Portal breakdown summed it up neatly: "Behind every over-engineered database stack is a team that never checked what PostgreSQL already does."

In 2026, it does a lot. With mature extensions, one PostgreSQL cluster handles 80–90% of typical workloads. Let's walk through all five pairs with real SQL and mark the line where a separate engine actually earns its keep.

JSONB and pgvector: Documents and AI Search Without MongoDB or Pinecone

Flexible data is usually the first trigger: payment webhooks, event logs, or forms with varying fields. Relational tables feel rigid here, so teams reach for MongoDB.

PostgreSQL has long offered JSONB, a binary JSON format that the query planner understands. To avoid scanning the entire table for nested keys, you add a GIN index (Generalized Inverted Index—think of it like a book index that maps keys directly to matching rows).

-- GIN index on a JSONB column
CREATE INDEX idx_events_payload
  ON events USING gin (payload);

-- Querying a nested field using the index
SELECT id, payload
FROM events
WHERE payload @> '{"type": "checkout"}';

The @> operator checks key-value containment and uses the index cleanly. Better yet, your documents sit right next to your users and orders, so you keep ACID transactions and standard JOIN queries. Developers who migrate off MongoDB almost always admit they missed normal joins more than they expected. Plus, you eliminate an entire connection pool and backup pipeline.

The second common reason to add another database is vector search for RAG. Instead of Pinecone or Chroma, you can install pgvector in Postgres (v0.8.7 branch, supporting PostgreSQL 13+, float, half-precision, binary and sparse vectors, plus quantization). It supports cosine distance (<=>), Euclidean L2 (<->), and inner product (<#>) out of the box.

-- Enable pgvector and build an HNSW index
CREATE EXTENSION IF NOT EXISTS vector;
CREATE INDEX idx_docs_emb
  ON docs USING hnsw (embedding vector_cosine_ops);

-- Find the five closest documents to a query vector
SELECT id, title
FROM docs
ORDER BY embedding <=> $1
LIMIT 5;

If your RAG service already talks to Postgres, pgvector removes an extra network hop and a separate API with its own quotas. Vectors live alongside business tables, so you can filter by permissions and similarity in a single query.

Keep the difference between HNSW (multi-layer graph) and IVFFlat (cluster-based) indexes in mind. HNSW gives higher accuracy and can be created on an empty table, but it builds slower and uses 2–5x more RAM. IVFFlat is lighter on memory, but you can't create it on an empty table—the clusters will be useless until you run REINDEX after loading data.

Typo-Tolerant Search and Time Series: tsvector, pg_trgm, and TimescaleDB

Once a project needs a search bar, someone immediately says "Elasticsearch." Next thing you know, the team spends weeks syncing data, chasing consistency bugs, and feeding RAM to a Java cluster.

Inside Postgres, combining tsvector, pg_trgm, and GIN gives you ranked full-text search, language dictionaries, autocomplete, and typo tolerance. The pg_trgm extension uses trigrams: it splits words into three-character chunks (pos, ost, stg) and measures overlap.

-- Enable trigrams and add a GIN index on the name column
CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE INDEX idx_items_name_trgm
  ON items USING gin (name gin_trgm_ops);

-- Search with typo tolerance and sort by similarity
SELECT name
FROM items
WHERE name % 'postgres'
ORDER BY similarity(name, 'postgres') DESC;

The % operator filters similar strings, and similarity ranks the closest matches at the top. The 80/20 rule applies here: Postgres handles roughly 80% of real-world search needs with zero sync lag—write a row, and it's searchable right away. Before spinning up Elasticsearch, make sure you're actually in the complex 20%.

The story with metrics and telemetry is even funnier. Most teams discover TimescaleDB (built by TigerData) only after setting up InfluxDB or Amazon Timestream—which is the only reason InfluxDB made this list.

Official TimescaleDB banner by TigerData, a PostgreSQL extension for time-series and analytics (Source: tigerdata.com)

TimescaleDB is an extension on top of PostgreSQL. It turns a metrics table into a hypertable: data is automatically partitioned by time intervals, old chunks get compressed, and continuous aggregates (precomputed summaries that incrementally refresh only recent data in the background) replace manual cron jobs.

-- Turn a metrics table into a time-partitioned hypertable
SELECT create_hypertable('metrics', by_range('ts'));

One line of SQL gives you automatic partitioning without learning Flux or InfluxQL and without writing a new runbook for on-call engineers. One small note for TimescaleDB 2.13+: if you need live querying of unmaterialized recent data (real-time aggregation), double-check that it's enabled on your continuous aggregates.

Events and Job Queues: LISTEN/NOTIFY, SKIP LOCKED, and pg-boss Instead of Redis

Teams often pull in Redis on day two for lightweight queues and pub/sub events without ever measuring what Postgres can handle.

For fast notifications, PostgreSQL includes LISTEN/NOTIFY: one process sends a signal to a channel, and subscribers pick it up. The docs note two strict limits: payloads max out at 8,000 bytes, and messages aren't persisted if a subscriber disconnects. Because of that, you pass only the row ID in NOTIFY and read the actual data from a table.

For durable queues, FOR UPDATE SKIP LOCKED does the heavy lifting. Multiple workers pull from the same table in parallel: each locks the first free job and skips rows already claimed by other workers without waiting.

-- Worker claims one free job without races or blocking
SELECT id, payload
FROM jobs
WHERE status = 'pending'
ORDER BY created_at
FOR UPDATE SKIP LOCKED
LIMIT 1;

You don't need to reinvent retries or timers either. For Node.js, pg-boss provides a production queue built on PostgreSQL transactions and SKIP LOCKED, complete with delayed jobs, retries, and singletons.

Of course, don't force it: Postgres will not replace Redis for sub-millisecond hot caches under heavy load or distributed rate limiters at tens of thousands of RPS. Just benchmark Postgres before adding another service.

Where "One Postgres" Ends: An Honest Boundary Map

A single cluster saves engineering time and eliminates sync drift until your workload hits a physical ceiling. Spin out a dedicated database only when your benchmarks prove you need it.

WorkloadSeparate DBPostgreSQL solutionWhen you actually need a separate DB
JSON documentsMongoDBJSONB + GINExtreme write throughput for huge, loosely coupled documents with built-in sharding
Vectors & RAGPinecone / Chromapgvector (HNSW / IVFFlat)Hundreds of millions or billions of vectors where HNSW no longer fits in RAM
Full-text searchElasticsearchtsvector + pg_trgm + GINComplex faceted analytics, custom morphology in dozens of languages, terabytes of logs
Time seriesInfluxDB / TimestreamTimescaleDB (hypertables)Ultra-dense telemetry that's better isolated from your main OLTP database
Queues & eventsRedis / brokersLISTEN/NOTIFY, SKIP LOCKED, pg-bossSub-1 ms caching or tens of thousands of messages/sec where VACUUM and MVCC choke

That last row is the most common real-world limit. Postgres uses MVCC (Multi-Version Concurrency Control: updates and deletes don't overwrite data in place; they mark old row versions for background VACUUM cleanup). At hundreds of jobs per second, the database barely notices. Once throughput reaches tens of thousands of events per second, constant rewrites bloat the table, and autovacuum starts fighting your main queries for disk I/O—that's when it's time for Kafka, RabbitMQ, or Redis.

Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 7