skillfed

llama-index-vector-stores-postgres

llama-index vector_stores postgres integration

llama-index-vector-stores-postgres v0.8.1 527.8K downloads/30d#6,169 on PyPI
Permissive license MIT Active released

What it is and what it does

This package bridges LlamaIndex and PostgreSQL by providing a vector store adapter that leverages the pgvector extension for storing and querying embeddings. It wraps the underlying database operations (via sqlalchemy, psycopg2-binary, and asyncpg) into a LlamaIndex-compatible interface, letting you use PostgreSQL as your embedding backend instead of a specialized vector database.

The integration supports five query modes: DEFAULT (standard similarity), HYBRID (dense + sparse), SPARSE (BM25 text), TEXT_SEARCH (full-text), and MMR (maximal marginal relevance for diverse results). You configure it by pointing to a PostgreSQL database and table, specifying embedding dimension, and then instantiate a PGVectorStore object that integrates directly with LlamaIndex's index and query engine APIs.

Use it for:

  • Store and retrieve embeddings from PostgreSQL when you already have Postgres infrastructure and want to avoid a separate vector database.
  • Implement hybrid search combining dense vector similarity with sparse BM25 text retrieval on the same dataset.
  • Use MMR queries to retrieve diverse, relevant results—useful for summarization or multi-faceted information retrieval.
  • Build full-text search on embeddings using PostgreSQL's native text search capabilities alongside vector operations.
  • Integrate vector search into existing LlamaIndex applications that already use Postgres for other data.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Integrates PostgreSQL with pgvector extension as a vector store backend for LlamaIndex, supporting multiple query modes including similarity search, hybrid retrieval, BM25 sparse search, full-text search, and maximal marginal relevance.

Yes, if you are building a LlamaIndex application and have PostgreSQL with pgvector already available. The package is actively maintained, has no known vulnerabilities, and low install friction. It is most valuable when you want to avoid adding a separate vector database and can leverage existing Postgres infrastructure. Not necessary if you prefer a dedicated vector store or do not use LlamaIndex.

Install

llama-index-vector-stores-postgres on PyPI

pip

pip install llama-index-vector-stores-postgres

uv

uv add llama-index-vector-stores-postgres

poetry

poetry add llama-index-vector-stores-postgres

Installing llama-index-vector-stores-postgres

Before you install

Low install friction with a pure-Python wheel and five runtime dependencies. Actively maintained as of 2026-03-13, with current Python support (3.10+). No known vulnerabilities.

License in practice

MIT license permits commercial and private use with minimal restrictions—suitable for most projects.

Quickstart

pip install llama-index-vector-stores-postgres

from llama_index.vector_stores.postgres import PGVectorStore

vector_store = PGVectorStore.from_params(
    database="your_database",
    host="localhost",
    password="your_password",
    port="5432",
    user="your_user",
    table_name="your_table",
    embed_dim=1536,
)

Requires a running PostgreSQL instance with pgvector extension installed and configured.

Verify before relying

  • Performance characteristics and scalability limits for large embedding collections.
  • Specific version compatibility matrix between llama-index-core and this integration.
  • Whether MMR query mode requires additional dependencies or configuration beyond pgvector.

Package facts

License MIT (permissive)
Python support supports the current Python release (<4.0,>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 5 — asyncpg, llama-index-core, pgvector, psycopg2-binary, sqlalchemy
Maintenance actively maintained — 154 days since the last release
First released
Downloads 527,763/month — #6,169 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: llama_index_vector_stores_postgres-0.8.1-py3-none-any.whl

Tags

postgres vector storepgvector llama indexpostgresql embedding storagevector database postgressemantic search postgreshybrid retrieval postgresmmr search postgres
vector-searchembeddingspostgres-integration

More Database packages

psycopg2-binary

psycopg2-binary is a PostgreSQL database…

copyleft · top 1,000 on PyPI

redis

Python client library for connecting to and…

permissive · top 1,000 on PyPI

ydb

YDB Python SDK is the official client library…

permissive · top 1,000 on PyPI

snowflake-connector-python

Connects Python applications to Snowflake data…

permissive · top 1,000 on PyPI

sqlparse

sqlparse tokenizes SQL text into a tree of…

permissive · top 1,000 on PyPI

dbt-adapters

Provides base adapter protocols and shared…

permissive · top 1,000 on PyPI

llama-index-vector-stores-redis

Integrates Redis as a vector store backend for…

permissive · top 15,000 on PyPI

llama-index-vector-stores-faiss

Integrates FAISS vector storage with LlamaIndex…

permissive · top 15,000 on PyPI

vecs

vecs is a Python client for storing, indexing,…

permissive · top 15,000 on PyPI

langchain-postgres

Provides LangChain abstractions for vector…

permissive · top 5,000 on PyPI

llama-index-vector-stores-qdrant

Integrates Qdrant vector database with…

permissive · top 15,000 on PyPI

llama-index-vector-stores-chroma

Integrates Chroma vector database with…

permissive · top 15,000 on PyPI

llama-index-retrievers-bm25

Integrates BM25 full-text search retrieval into…

permissive · top 15,000 on PyPI

llama-index-vector-stores-milvus

Integrates the Milvus vector database with…

permissive · top 15,000 on PyPI

pgserver

Embeds a PostgreSQL server with pgvector…

unclear · top 15,000 on PyPI

sqlite-vec

sqlite-vec adds vector search capabilities to…

permissive · top 5,000 on PyPI