timescale avatar

Pgvector Semantic Search

This is the reference implementation for pgvector semantic search. It defaults to HNSW indexes with halfvec storage for cosine distance, which gives you 50% smaller indexes and solid recall without much tuning. The guide is opinionated in the right ways: it tells you to skip IVFFlat unless you have write-heavy workloads, gives you actual ef_search numbers tied to recall tradeoffs, and includes rough capacity estimates so you know when 16GB RAM hits its limit around 2-3M vectors at 1536 dimensions. If you're building RAG or any embeddings-based search on Postgres, this cuts through the parameter space and gets you to production faster.

skills.sh installs
991
GitHub stars
1.9K
last updated
Aug 21, 2026

Install

$ npx -y skills add timescale/pg-aiguide --skill pgvector-semantic-search --agent claude-code

Installs into .claude/skills of the current project.

Files

pgvector for Semantic Search

Semantic search finds content by meaning rather than exact keywords. An embedding model converts text into high-dimensional vectors, where similar meanings map to nearby points. pgvector stores these vectors in PostgreSQL and uses approximate nearest neighbor (ANN) indexes to find the closest matches quickly—scaling to millions of rows without leaving the database. Store your text alongside its embedding, then query by converting your search text to a vector and returning the rows with the smallest distance.

This guide covers pgvector setup and tuning—not embedding model selection or text chunking, which significantly affect search quality. Requires pgvector 0.8.0+ for all features (halfvec, binary_quantize, iterative scan).

Golden Path (Default Setup)

Sponsors

Details

Repository
github.com/timescale/pg-aiguide
Categories
Backend & APIs, AI & Agent Building, Data Science & ML, Debugging, Marketing & SEO, Databases
First seen
Jun 3, 2026

More from timescale/pg-aiguide

All 8
1builderio avatarvisual-recapbuilderio/skillsTurn a PR, branch, commit, or git diff into an interactive visual recap with diagrams, file maps, API/schema summaries, annotated diffs, and focused review note984skills.sh installs
2daymade avatarcloudflare-troubleshootingdaymade/claude-code-skillsInvestigate and resolve Cloudflare configuration issues using API-driven evidence gathering. Use when troubleshooting ERR_TOO_MANY_REDIRECTS, SSL errors, DNS is978skills.sh installs
3mindrally avatarnestjs-clean-typescriptmindrally/skillsClean NestJS API development with TypeScript following SOLID principles, modular architecture, and comprehensive testing practices.974skills.sh installs
4product-on-purpose avatardeliver-user-storiesproduct-on-purpose/pm-skillsGenerates user stories in the standard persona, action, benefit story format from product requirements or feature descriptions. Use when breaking a feature into953skills.sh installs
5mohitmishra786 avatarllvmmohitmishra786/low-level-dev-skillsLLVM IR and pass pipeline skill. Use when working directly with LLVM Intermediate Representation (IR), running opt passes, generating IR with llc, inspecting or948skills.sh installs
6supermemoryai avatarsupermemorysupermemoryai/skillsSupermemory is a state-of-the-art memory and context infrastructure for AI agents. Use this skill when building applications that need persistent memory, user p943skills.sh installs