Azure Database for PostgreSQL (pgvector) in 60 seconds
DatabasesPaaS (relational)AWS: Amazon RDS for PostgreSQL
What it is
Managed PostgreSQL flexible server. Allow the pgvector extension to store embeddings in vector columns and search them with HNSW or IVFFlat indexes, right next to your relational data.
Simulate it »✅ Use it when
- RAG over documents with metadata filters
- Apps that already use PostgreSQL
- SQL joins plus similarity search in one query
🚫 Not the best fit when
- Global multi-region writes (Cosmos DB fits better)
💰 Price feel: ●●○○ Low
Burstable B1ms ≈ $13/month; General Purpose D2ds v5 ≈ $125/month plus storage
Illustrative pay-as-you-go list prices at approximate exchange rates. Use the Azure pricing calculator for real quotes.
Simulate it
🖱️ Drag to rotate · scroll or pinch to zoom
PostgreSQL with pgvector
In Azure Database for PostgreSQL, the pgvector extension adds a vector(1536) column type. Without an index, every search compares against every row (a sequential scan). An HNSW or IVFFlat index finds near neighbours fast, trading a little recall for a lot of speed.
🤔 What happens if…
Read this tour as text
- Text becomes a vector. An embedding model turns text into a list of numbers, a vector (1,536 numbers for
text-embedding-3-small). Texts that mean similar things get vectors that sit close together, so "refund" lands near "money back". - Cosmos DB: items, partitions, RUs. In Azure Cosmos DB for NoSQL, JSON items live in containers, spread across logical partitions by the partition key. Every operation costs Request Units (RUs). A point read by id and partition key costs about 1 RU. A query that scans every partition costs far more.
- Indexing and consistency. By default Cosmos DB indexes every property, so writes cost more RUs. An indexing policy can exclude paths you never filter on, such as the big
embeddingarray. Consistency levels trade freshness for speed and cost: Strong, Bounded staleness, Session (default), Consistent prefix, Eventual. - Vector search in Cosmos DB. A vector embedding policy tells Cosmos DB where the vectors are, their dimensions and distance function. A vector index makes search fast:
diskANNorquantizedFlatfor large sets, orflatfor exact search on small vectors (up to 505 dimensions). ThenORDER BY VectorDistance(c.embedding, @q)returns the closest items. - Change feed. The change feed is an ordered log of inserts and updates in a container (deletes only show up in the *all versions and deletes* mode). A change feed processor reads it with a lease container that remembers how far each worker got, so a new product can be embedded the moment it’s saved.
- PostgreSQL with pgvector. In Azure Database for PostgreSQL, the pgvector extension adds a
vector(1536)column type. Without an index, every search compares against every row (a sequential scan). An HNSW or IVFFlat index finds near neighbours fast, trading a little recall for a lot of speed. - RAG with a metadata filter. Retrieval-augmented generation (RAG): embed the question, fetch the closest chunks (
ORDER BY embedding <=> $1 LIMIT 5), filter by metadata such astenant_idorlang, then send those chunks to the model as context. The answer is grounded in your own data. - Azure Managed Redis. Azure Managed Redis keeps hot data in memory. Cache-aside: check Redis, and on a miss read the database and store the result with a TTL. When data changes, invalidate the key. Redis can also hold a vector index for fast similarity search, for example a semantic cache of answers.