postgres-vectors

Store 384-dimensional embeddings in Postgres and query cosine similarity with pgvector.

Updated Oct 26, 2025
One-click install
npx skills add https://github.com/discountedcookie/10x-mapmaster --skill postgres-vectors
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres-vectors
Source: https://github.com/discountedcookie/10x-mapmaster/tree/main/.opencode/skills/postgres-vectors
Command: npx skills add https://github.com/discountedcookie/10x-mapmaster --skill postgres-vectors

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides patterns for vector storage, distance operators, index strategies, and similarity queries in PostgreSQL using pgvector (384-d embeddings).

Core Features & Use Cases

  • Store 384-d embeddings in a dedicated table
  • Use cosine distance (<=>) for similarity queries
  • Choose indexing strategy (HNSW vs IVFFlat) and tune parameters
  • Find and batch-calculate similarity across multiple items

Quick Start

Create the embeddings table and run a cosine similarity query to find similar embeddings.

Frequently Asked Questions about postgres-vectors

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

FAQPage Schema
How do I store and search embeddings with vector similarity in Postgres?

Vector similarity in Postgres uses pgvector to store 384-dimensional embeddings and query them with cosine distance operators. Create a table with vector(384) columns, then use the <=> operator to find similar embeddings by computing cosine distance across stored vectors.

What indexing strategies work best for semantic search on large embedding datasets?

Semantic search on embeddings scales with two index strategies: HNSW for hierarchical navigation with tuned parameters, or IVFFlat for inverted flat clustering with quantization. Choose HNSW for high recall or IVFFlat for lower memory overhead on large 384-dimensional vector sets.

Can I deduplicate embeddings by source text in Postgres?

Yes, deduplication by source_text prevents redundant embeddings in your table. Apply unique constraints or filter queries on source_text to ensure each embedding stores only once, reducing storage and query overhead.

How do I batch-calculate cosine similarity across multiple embeddings?

Batch cosine similarity queries use the <=> operator to compute distances between a query embedding and all stored vectors in a single SQL statement. Order results by distance and limit to retrieve the top matches efficiently.

Does pgvector support 384-dimensional embeddings without extension setup?

No, pgvector requires the vector extension installed in the extensions schema and a column defined as vector(384) to store 384-dimensional embeddings. Create the extension and table structure before inserting or querying embedding data.

What's the difference between HNSW and IVFFlat indexing for vector search?

HNSW provides better recall and query speed through hierarchical graph navigation, while IVFFlat clusters vectors for lower memory use and faster index builds. Choose HNSW for accuracy-critical search or IVFFlat for cost-constrained large-scale deployments.