pgvector-specialist

Store and query embeddings in PostgreSQL using the pgvector extension.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/Whaleylaw/llm-lawyer --skill pgvector-specialist
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pgvector-specialist
Source: https://github.com/Whaleylaw/llm-lawyer/tree/main/.claude/skills/pgvector-specialist
Command: npx skills add https://github.com/Whaleylaw/llm-lawyer --skill pgvector-specialist

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill provides clear, actionable guidance to implement and optimize vector similarity search and to store AI-generated embeddings in PostgreSQL/Supabase using the pgvector extension, addressing slow similarity queries, embedding dimension mismatches, and missing vector indexes.

Core Features & Use Cases

  • Enable and verify pgvector: steps to install or confirm the pgvector extension in Supabase and self-hosted PostgreSQL.
  • Schema and embedding storage: patterns for creating tables with vector columns, storing metadata, and generating embeddings from AI models.
  • Indexing and performance tuning: recommendations for IVFFlat and HNSW indexes, VACUUM ANALYZE, and tuning probes/ef_search for production workloads.
  • Similarity and hybrid queries: examples for cosine, L2, and inner-product searches and combining vector search with metadata filters for hybrid relevance.
  • Operational best practices: upserts, batch inserts, dimension validation, stored functions for reusable search, and Supabase-specific deployment tips.

Quick Start

Generate embeddings for your documents, store them in a documents table with a vector column, create an appropriate vector index, and run a cosine similarity query to return the top matching rows.

Frequently Asked Questions about pgvector-specialist

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

FAQPage Schema
How do I store and query AI embeddings in PostgreSQL for semantic search?

To store and query AI embeddings in PostgreSQL for semantic search, you enable the pgvector extension, create tables with vector columns for your embeddings and metadata, and run similarity queries like cosine distance to find matching rows.

Can I use pgvector with Supabase to build a recommendation system?

Yes, you can use pgvector with Supabase to build a recommendation system. Supabase supports the pgvector extension natively, allowing you to store embeddings alongside metadata and perform vector similarity searches for recommendations.

What's the best way to optimize slow vector similarity queries in pgvector?

The best way to optimize slow vector similarity queries in pgvector is to build IVFFlat or HNSW vector indexes, run VACUUM ANALYZE, and tune query parameters like ivfflat.probes or hnsw.ef_search for your production workloads.

How do I combine vector similarity search with metadata filters in PostgreSQL?

You combine vector similarity search with metadata filters in PostgreSQL by writing hybrid queries that join vector distance calculations with standard WHERE clause conditions on metadata columns, enabling filtered semantic retrieval.

Why do my pgvector embeddings fail to insert due to dimension mismatches?

Your pgvector embeddings fail to insert due to dimension mismatches when the vector column schema dimensions do not match the output dimensions of your AI model. Consistent embedding dimensions are required for pgvector operations.

Do I need to create vector indexes for pgvector to work?

While pgvector can perform exact nearest neighbor searches without indexes, you need to create IVFFlat or HNSW vector indexes for production performance to enable approximate nearest neighbor search and significantly speed up similarity queries.