Prompt

self hosted vector search PostgreSQL

Technology / Databases1 observationLast seen Oct 7, 2026

Latest observation

Oct 7, 2026OpenAI APIWeb search: off

If you want a self-hosted vector search setup using PostgreSQL, the usual choice is:

Use PostgreSQL + pgvector

pgvector is a PostgreSQL extension that adds vector data types and similarity search.

Why this is a good option

  • Runs on your own infrastructure
  • Simple if you already use Postgres
  • Supports approximate and exact vector similarity search
  • Works well for moderate-scale semantic search, embeddings, RAG, recommendations, etc.

Basic setup

1. Install PostgreSQL

Use your usual self-hosting method:

  • Docker
  • VM/bare metal
  • Kubernetes
  • Managed-but-self-controlled Postgres

2. Install pgvector

If using Docker, simplest is an image that includes it, or install the extension package on your server.

Example SQL:

CREATE EXTENSION IF NOT EXISTS vector;

Example table

CREATE TABLE documents (
    id bigserial PRIMARY KEY,
    content text,
    embedding vector(1536)
);

1536 is just an example dimension — match it to your embedding model.


Insert vectors

INSERT INTO documents (content, embedding)
VALUES (
  'hello world',
  '[0.12, 0.34, ...]'
);

Search by similarity

Cosine distance example:

SELECT id, content
FROM documents
ORDER BY embedding <=> '[0.11, 0.33, ...]'
LIMIT 10;

Operators:

  • <=> cosine distance
  • <-> Euclidean distance
  • <#> negative inner product

Add an index for performance

HNSW index

Good for high-quality approximate nearest-neighbor search:

CREATE INDEX ON documents
USING hnsw (embedding vector_cosine_ops);

IVFFlat index

Another option, often used for large datasets:

CREATE INDEX ON documents
USING ivfflat (embedding vector_cosine_ops)
WITH (lists = 100);

When PostgreSQL is enough

Postgres + pgvector is a great fit if:

  • You have up to millions of vectors
  • You want operational simplicity
  • You need metadata filters plus vector search in one query
  • You don’t need a dedicated vector database

When to consider a dedicated vector DB instead

Consider alternatives if you need:

  • Very large-scale ANN search
  • Very high QPS
  • Low-latency distributed vector search
  • Advanced vector-native features

Examples:

  • Qdrant
  • Milvus
  • Weaviate
  • OpenSearch vector search

Common stack for self-hosted RAG

  • PostgreSQL + pgvector for embeddings
  • Application backend in Python/Node/Go
  • Embedding model via OpenAI/local models
  • Full-text search with Postgres tsvector if needed

If you want, I can also give you:

  1. a Docker Compose example for Postgres + pgvector,
  2. a Python example for inserting/searching vectors, or
  3. a production setup guide for self-hosted deployment.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.