Search overlay panel for performing site-wide searches
Salesforce (Heroku) Named a Leader. Learn More!

pgvector for Heroku Postgres

Get Started Now

Power your applications with vector search using pgvector for Heroku Postgres

Image for: Power your applications with vector search using pgvector for Heroku Postgres

Add powerful vector similarity search to your applications by enabling the pgvector extension on Heroku Postgres. Store embeddings and perform operations like semantic search, RAG, and recommendations directly within your trusted database.

View pgvector Docs Get Started With Heroku Postgres

Why pgvector on Heroku?

Image for: Why pgvector on Heroku?

Flexible data management

Store vector embeddings alongside your relational data in Heroku Postgres. Simplify your architecture and workflows by managing all your data in one place with familiar tools and practices.

Optimized performance

Leverage indexing options like HNSW and IVFFlat for efficient approximate nearest neighbor (ANN) search. Fine-tune performance with parallel workers for queries and index builds on large datasets.

Simple activation & use

Enable the pgvector extension on compatible Heroku Postgres plans with a single SQL command. Easily add vector columns to new or existing tables and query using intuitive operators (<->, <#>, <=>).

Leverage Heroku’s reliability

Build your AI features on the proven reliability, security, and scalability of Heroku Postgres and the Heroku AI platform, benefiting from managed infrastructure and automated maintenance.

How pgvector works on Heroku

Image for: How pgvector works on Heroku

Enable the extension

Connect to your Heroku Postgres database (version 15+ recommended for full features) using heroku pg:psql and run CREATE EXTENSION vector;.

Define vector columns

Add a vector(DIMENSIONS) column to new or existing tables, specifying the number of dimensions your embeddings will have (e.g., vector(1024)).

Insert & query vectors

Insert your vector embeddings. Use SQL operators like Euclidean distance (<->), cosine similarity (<=>), or negative inner product (<#>) to perform similarity searches.

Index for performance

For larger datasets, create HNSW or IVFFlat indexes on your vector columns to significantly speed up approximate nearest neighbor searches.

Common use cases

Image for: Common use cases

Custom AI applications

Quickly develop AI features using Heroku AI inference and MCP Server, augmented by pgvector. Connect your app, AI, and users effectively by implementing vector search on Postgres with your own vector database.

Retrieval-augmented generation (RAG)

Retrieve relevant documents or data snippets (like product docs) from your database to augment prompts for LLMs, improving response accuracy and context.

Recommendations

Build recommendation engines by finding vectors similar to a user’s interaction history or item attributes (e.g., similar products, songs, articles).

Semantic search

Go beyond keyword matching. Find documents, support cases (synced via Heroku Connect), or other text data based on semantic meaning and context.

Multimedia search

Search across images, audio, or video content by embedding the content itself or associated metadata/transcriptions.

Anomaly detection

Identify unusual patterns or outliers in datasets like network traffic, sensor readings, or financial transactions by finding vectors that deviate from the norm.

Data categorization

Segment and categorize complex data (e.g., patient records, genomic sequences) by grouping similar vectors to aid analysis and identification.

Get started with pgvector On Heroku

Image for: Get started with pgvector On Heroku

Add pgvector to your existing Heroku Postgres database and start building intelligent features today.

View Heroku Postgres Plans Sign Up Now