A Postgres extension in Rust that adds a DiskANN-based index and label filtering on top of pgvector for faster, cheaper vector search.
pgvector/pgvector-go
Go support for the pgvector PostgreSQL extension, with vector types and helpers for pgx, pg, Bun, Ent, GORM and sqlx.
- Stars
- 356
- Forks
- 16
- Open issues
- 0
- Last commit
- 2 days ago
What is it?
pgvector-go is a Go library that lets applications store and query vector embeddings in PostgreSQL through the pgvector extension. It provides Go types for dense vectors, half vectors and sparse vectors, along with adapters so these types work directly with pgx, pg, Bun, Ent, GORM and sqlx.
The library covers the common workflow: enabling the extension, defining a vector column, inserting embeddings, and running nearest-neighbor queries with distance operators such as L2, inner product and cosine. It also shows how to create HNSW or IVFFlat indexes for approximate search. Ent integration includes helpers for several distance functions.
Examples in the repository cover OpenAI and Cohere embeddings, hybrid search with Reciprocal Rank Fusion, sparse search, recommendations, Citus horizontal scaling and bulk loading with COPY.
Key features
- 01Go types for dense, half and sparse vectors
- 02Adapters for pgx, pg, Bun, Ent, GORM and sqlx
- 03Nearest-neighbor queries with L2, inner product and cosine distance operators
- 04HNSW and IVFFlat index creation examples
- 05Examples for OpenAI, Cohere, hybrid search and bulk loading with COPY
Use cases
- Adding semantic search or retrieval to a Go service backed by PostgreSQL
- Storing text or image embeddings alongside relational data
- Building recommendation features that rank items by vector similarity
- Loading large embedding datasets into PostgreSQL efficiently
Quick start
- 1
Install the core Go package
go get github.com/pgvector/pgvector-go - 2
Install the pgx integration package
go get github.com/pgvector/pgvector-go/pgx - 3
Enable the pgvector extension in PostgreSQL
CREATE EXTENSION IF NOT EXISTS vector
Things to know
- Requires PostgreSQL with the pgvector extension installed on the server.
In collections
Topics
FAQ
- What is pgvector-go?
- Go support for the pgvector PostgreSQL extension, with vector types and helpers for pgx, pg, Bun, Ent, GORM and sqlx. pgvector-go is a Go library that lets applications store and query vector embeddings in PostgreSQL through the pgvector extension. It provides Go types for dense vectors, half vectors and sparse vectors, along with adapters so these types work directly with pgx, pg, Bun, Ent, GORM and sqlx.
- Is pgvector-go free to use? What license does it have?
- pgvector-go is open source under the MIT license. Check the license terms before using it in commercial products.
- Is pgvector-go still maintained?
- Actively maintained. The last commit to pgvector-go was on Nov 5, 2026.
- What can I use pgvector-go for?
- Adding semantic search or retrieval to a Go service backed by PostgreSQL Storing text or image embeddings alongside relational data Building recommendation features that rank items by vector similarity Loading large embedding datasets into PostgreSQL efficiently
- How do I install pgvector-go?
- Install the core Go package: go get github.com/pgvector/pgvector-go Install the pgx integration package: go get github.com/pgvector/pgvector-go/pgx Enable the pgvector extension in PostgreSQL: CREATE EXTENSION IF NOT EXISTS vector
- Where can I get pgvector-go?
- The source code and installation instructions are on GitHub: https://github.com/pgvector/pgvector-go
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Python library that adds pgvector vector-type and similarity search support to Django, SQLAlchemy, Psycopg, asyncpg, Peewee and other PostgreSQL drivers.
JavaScript and TypeScript helper library that adds pgvector vector type support to Node.js, Deno, and Bun database clients and ORMs.
Milvus is an open-source, distributed vector database for storing and searching embeddings at scale, used for AI search and RAG applications.
Qdrant is a Rust-based vector similarity search engine and vector database with payload filtering, for semantic search and recommendation.
Open-source vector similarity search extension for Postgres, storing and querying embeddings alongside your relational data.