pgvector-semantic-search

Store, index, and query embeddings in PostgreSQL with pgvector.

1.8k|104|Updated Jul 23, 2025
One-click install
npx skills add https://github.com/timescale/pg-aiguide --skill pgvector-semantic-search
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pgvector-semantic-search
Source: https://github.com/timescale/pg-aiguide/tree/main/skills/pgvector-semantic-search
Command: npx skills add https://github.com/timescale/pg-aiguide --skill pgvector-semantic-search

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill enables storing, indexing, and querying high-dimensional embeddings inside PostgreSQL using pgvector, enabling scalable similarity search without leaving the database.

Core Features & Use Cases

  • Vector storage & indexing: store embeddings as pgvector types and build ANN indexes (HNSW, IVFFlat) for fast retrieval.
  • RAG integrations: support Retrieval-Augmented Generation pipelines by retrieving relevant vectors and documents for downstream tasks.
  • Performance optimization: guidance on quantization, dimensionality considerations, memory tuning, and query patterns for large datasets.
  • Use Case: Build a semantic search over documents or chat results with vector-based retrieval and ranking.

Quick Start

Install and configure the pgvector extension in your PostgreSQL database, create a vector column (halfvec or vector), and build an index (e.g., ON ... USING hnsw). Then run a nearest-neighbor query to retrieve similar items using a sample embedding.

Frequently Asked Questions about pgvector-semantic-search

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build semantic search with PostgreSQL and pgvector?

To build semantic search with PostgreSQL and pgvector, install the extension, create a vector column to store embeddings, and build an index using HNSW or IVFFlat for fast nearest-neighbor retrieval.

What is the best way to index high-dimensional embeddings in PostgreSQL for RAG applications?

The best way to index high-dimensional embeddings for RAG applications in PostgreSQL is using pgvector's HNSW or IVFFlat indexes, which enable fast and scalable similarity searches directly inside the database.

Does pgvector support performance tuning for large vector datasets?

Yes, pgvector supports performance tuning for large vector datasets through quantization, dimensionality considerations, memory tuning, and optimized query patterns to ensure fast retrieval.

When should I use HNSW vs IVFFlat indexes for vector similarity search?

You should choose between HNSW and IVFFlat indexes for vector similarity search based on your specific dataset scale and memory constraints, using pgvector's configuration options to balance retrieval speed and accuracy.

Can I use pgvector for RAG pipelines without leaving my PostgreSQL database?

Yes, you can use pgvector for RAG pipelines without leaving PostgreSQL, enabling you to store, index, and query high-dimensional embeddings directly alongside your relational data for retrieval-augmented generation.