vector. CREATE EXTENSION pgvector; fails. Always use CREATE EXTENSION vector;.
Validated on 27 Apr 2026 • Last edited on 27 Apr 2026
DigitalOcean Managed PostgreSQL for vector search uses the same managed PostgreSQL engine available under Managed Databases, with the pgvector and pgvectorscale extensions for storing and querying vector embeddings alongside relational data.
This quickstart walks you through creating a DigitalOcean Managed PostgreSQL cluster, enabling the pgvector extension, storing a handful of sample embeddings, and running a similarity search. It takes about 10 minutes.
psql installed.For full options, see Create a PostgreSQL Cluster.
On the cluster’s Overview tab:
See Secure PostgreSQL Clusters with Trusted Sources for details.
Connect with psql and enable the extension:
psql "postgresql://doadmin:PASSWORD@HOST:25060/defaultdb?sslmode=require"CREATE EXTENSION IF NOT EXISTS vector;
\dx vectorvector. CREATE EXTENSION pgvector; fails. Always use CREATE EXTENSION vector;.
Create a table with a vector column sized to match your embedding model. This example uses 1,536 dimensions, which matches OpenAI text-embedding-3-small.
CREATE TABLE documents (
id bigserial PRIMARY KEY,
content text NOT NULL,
embedding vector(1536),
created_at timestamptz NOT NULL DEFAULT now()
);Generate an embedding in your application, then insert it:
INSERT INTO documents (content, embedding) VALUES ($1, $2);pgvector accepts vectors in the textual form [v1, v2, ...].
Given a query embedding, return the five most similar documents ordered by cosine distance:
SELECT id, content, 1 - (embedding <=> $1) AS cosine_similarity
FROM documents
ORDER BY embedding <=> $1
LIMIT 5;For production workloads, add an HNSW index to the embedding column. See Index and Tune Vector Search.
Try using different keywords or simplifying your search terms.