GrepAI Storage with PostgreSQL
This skill covers using PostgreSQL with the pgvector extension as the storage backend for GrepAI.
When to Use This Skill
- Team environments with shared index
- Large codebases (10K+ files)
- Need concurrent access
- Integration with existing PostgreSQL infrastructure
Prerequisites
- PostgreSQL 14+ with pgvector extension
- Database user with create table permissions
- Network access to PostgreSQL server
Advantages
Setting Up PostgreSQL with pgvector
Option 1: Docker (Recommended for Development)
Option 2: Install on Existing PostgreSQL
Then enable the extension:
Option 3: Managed Services
- Supabase: pgvector included by default
- Neon: pgvector available
- AWS RDS: Install pgvector extension
- Azure Database: pgvector available
Configuration
Basic Configuration
With Environment Variable
Set the environment variable:
Full DSN Options
DSN components:
user: Database usernamepassword: Database passwordhost: Server hostname or IP5432: Port (default: 5432)database: Database namesslmode: SSL mode (disable, require, verify-full)
SSL Modes
Database Schema
GrepAI automatically creates these tables:
Verifying Setup
Check pgvector Extension
Test Connection from GrepAI
Performance Tuning
PostgreSQL Configuration
For better vector search performance:
Index Tuning
For large indices, tune the IVFFlat index:
Rule of thumb: lists = sqrt(rows)
Concurrent Access
PostgreSQL handles concurrent access automatically:
- Multiple
grepai searchcommands work simultaneously - One
grepai watchdaemon per codebase - Many users can share the same index
Team Setup
Shared Database
All team members point to the same database:
Per-Project Databases
For isolated projects, use separate databases:
Backup and Restore
Backup
Restore
Migrating from GOB
- Set up PostgreSQL with pgvector
- Update configuration:
- Delete old index:
- Re-index:
Common Issues
❌ Problem: FATAL: password authentication failed
✅ Solution: Check DSN credentials and pg_hba.conf
❌ Problem: ERROR: extension "vector" is not available
✅ Solution: Install pgvector:
❌ Problem: ERROR: type "vector" does not exist
✅ Solution: Enable extension in the database:
❌ Problem: Connection refused ✅ Solution:
- Check PostgreSQL is running
- Verify host and port
- Check firewall rules
❌ Problem: Slow searches ✅ Solution:
- Add IVFFlat index
- Increase
work_mem - Vacuum and analyze tables
Best Practices
- Use environment variables: Don't commit credentials
- Enable SSL: For remote databases
- Regular backups: pg_dump before major changes
- Monitor performance: Check query times
- Index maintenance: Regular VACUUM ANALYZE
Output Format
PostgreSQL storage status:


