pgvector-semantic-search

Store embeddings in PostgreSQL with pgvector and run cosine-distance queries.

Updated Feb 3, 2026
One-click install
npx skills add https://github.com/ThaiG2Pro/ai-agent-sale-v1 --skill pgvector-semantic-search-thaig2pro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pgvector-semantic-search
Source: https://github.com/ThaiG2Pro/ai-agent-sale-v1/tree/main/.gemini/skills/pgvector-semantic-search
Command: npx skills add https://github.com/ThaiG2Pro/ai-agent-sale-v1 --skill pgvector-semantic-search-thaig2pro

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Stores embeddings in PostgreSQL with pgvector and uses HNSW indexes to enable fast semantic search within the database, avoiding external inference bottlenecks.

Core Features & Use Cases

  • In-database vector storage using halfvec(N) to minimize storage overhead.
  • High-speed cosine-distance queries with HNSW indexing for scalable similarity search.
  • Use cases include content retrieval, product recommendations, and semantic search over text corpora.

Quick Start

Configure your database to enable the pgvector extension, create a vector column, index with HNSW, and run a sample cosine-distance nearest-neighbor query.

Frequently Asked Questions about pgvector-semantic-search

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

FAQPage Schema
How do I perform semantic search in PostgreSQL using pgvector?

Semantic search in PostgreSQL uses pgvector to store embeddings and perform cosine-distance queries. You enable the extension, add a vector column, and query using nearest-neighbor operators to find similar content.

What is the best way to scale vector search queries in a PostgreSQL database?

Scaling vector search in PostgreSQL relies on creating HNSW indexes on your vector columns. HNSW indexing accelerates cosine-distance queries, enabling fast similarity matching across large text corpora or product catalogs.

Can I use half precision vectors with pgvector to reduce storage overhead?

Yes, pgvector supports in-database vector storage using halfvec(N) to minimize storage overhead. This allows you to store half-precision embeddings directly in PostgreSQL while maintaining semantic search capabilities.

How do I set up HNSW indexing for cosine distance queries?

To set up HNSW indexing for cosine distance queries, enable the pgvector extension, create a vector column, and apply the HNSW index. This configuration supports high-speed nearest-neighbor queries for similarity search.

Does pgvector work for product recommendations and content retrieval?

Yes, pgvector is designed for database-centric applications needing scalable in-database vector search. It handles content retrieval, product discovery, and similarity-based recommendations directly within PostgreSQL.