Part 3: Setting Up pgvector with PostgreSQL
The $400/Month Bill That Made Me Switch
Installing PostgreSQL with pgvector
macOS (Homebrew)
Linux (Ubuntu/Debian)
Docker (Easiest for Development)
Docker Compose (My Production Setup)
Enabling and Verifying pgvector Extension
Creating Tables with Vector Columns
Basic Vector Column
Complete Schema with Metadata
Vector Column for Documentation
Vector Indexes: HNSW vs IVFFlat
HNSW Index (Recommended)
IVFFlat Index
Which Index Should You Use?
Use Case
Index Type
Configuration
Create Index After Loading Data
Prisma Schema for pgvector
Migration
Loading Embeddings into PostgreSQL
Method 1: Prisma with Raw SQL (Recommended)
Method 2: Bulk Insert with COPY (Fastest)
Method 3: Transaction for Consistency
Testing Vector Queries
Basic Similarity Search
With TypeScript
Verify Index Usage
Performance Tuning
Set Work Memory for Index Building
Query Performance Tuning
Monitor Query Performance
Common Issues and Solutions
Issue: Index not being used
Issue: Slow index creation
Issue: Out of memory
Complete Setup Script
What's Next
Last updated