FTN FineTunedNews
Data

Postgres gets native vector indexes: what changes for search

PgVector 0.8 lands with HNSW improvements and better ANN performance for multi-tenant apps.

Postgres gets native vector indexes: what changes for search

title: "Postgres gets native vector indexes: what changes for search", deck: "PgVector 0.8 lands with HNSW improvements and better ANN performance for multi-tenant apps.", date: "2025-08-22", category: "Data", author: "FTN Data Desk", image: "/images/articles/postgres.png", draft: false };

Postgres has long been the workhorse of relational databases. Now it is becoming an AI-first database too. With native vector indexes (HNSW and IVFFlat) integrated into Postgres core extensions, developers no longer need separate vector databases to power semantic search, recommendation systems, or AI retrieval workflows.

References:


Why This Matters

  • One database, fewer moving parts: store relational and vector data together
  • Performance: HNSW indexes speed up nearest-neighbor search
  • Ecosystem: seamless use with ORMs, SQL clients, and cloud Postgres providers

What Changed

  • IVFFlat was already supported but required careful tuning
  • HNSW is now available and generally faster for approximate nearest neighbor (ANN) queries
  • Parallel search and better LIMIT query optimizations reduce latency

Example Setup

-- Enable the extension
CREATE EXTENSION IF NOT EXISTS vector;

-- Create a table with an embedding column
CREATE TABLE documents (
  id bigserial PRIMARY KEY,
  content text,
  embedding vector(768)
);

-- Create an HNSW index
CREATE INDEX ON documents
USING hnsw (embedding vector_l2_ops);

Querying Vectors

-- Find the 5 nearest neighbors to a query embedding
SELECT id, content
FROM documents
ORDER BY embedding <-> '[0.12, 0.98, ...]'
LIMIT 5;

Best Practices

  • Dimension must match the embedding model (e.g., 768 for OpenAI text-embedding-3-small)
  • Normalize vectors before insert if you plan cosine similarity
  • Use batch inserts for efficiency and VACUUM ANALYZE after large imports

Real World Use Cases

  • Semantic document search directly inside Postgres
  • Hybrid queries combining metadata filters with ANN
  • AI copilots and RAG pipelines without a separate vector DB

Final Thought

Native vector indexing makes Postgres a true all-in-one database for modern apps. Instead of bolting a separate vector database onto your stack, you can now build AI search features directly in the same Postgres instance powering your business logic. For many teams, that means faster iteration, simpler infra, and fewer 3am pager calls.

Support FineTunedNews

At FineTunedNews we believe that everyone whetever his finacial state should have accurated and verified news. You can contribute to this free-right by helping us in the way you want. Click here to help us.

Help us
© 2025 FineTunedNews. All rights reserved.
Postgres gets native vector indexes: what changes for search · FineTunedNews