Quick Start
pgvector Backend
The default backend using PostgreSQL with the pgvector extension. Recommended for production.Setup
Start PostgreSQL with pgvector
Use the official pgvector Docker image:Or install pgvector on existing PostgreSQL:
docker-compose.yml
Configure Postgrex Types
Create a Postgrex types module:Add to your repo config:
lib/my_app/postgrex_types.ex
config/config.exs
Features
Persistent Storage
Data survives restarts and can be backed up like any PostgreSQL database.
Scalable
Handles millions of vectors with proper indexing (IVFFlat, HNSW).
Hybrid Search
Combines vector similarity with PostgreSQL full-text search in a single query.
ACID Guarantees
Transactions, consistency, and reliability of PostgreSQL.
Hybrid Search
pgvector supports combining semantic and full-text search:Hybrid search uses min-max normalization to fairly combine semantic scores (0-1 range) with full-text scores (variable range).
Indexing
For large datasets, create vector indexes:- IVFFlat Index
- HNSW Index
Best for: 10K-1M vectorsTrade-offs:
- Fast queries
- Good recall (~95%)
- Requires training data
Performance Tuning
In-Memory Backend (HNSWLib)
Fast in-memory vector storage using HNSWLib. Perfect for development, testing, and small datasets.Setup
Usage
Features
Fast Startup
No database setup required - start searching immediately.
Great for Testing
Reset state between tests with
clear/2.Low Latency
In-memory search is faster than database queries.
Limited Scale
Recommended for under 100K vectors per collection.
Options
Limitations
- No full-text search (semantic only)
- No persistence
- Single-node only
- Higher memory usage
Custom Vector Store
Implement theArcana.VectorStore behaviour for custom backends (Pinecone, Weaviate, Qdrant, etc.).
Implementation
Configuration
Per-Call Override
Choosing a Backend
| Backend | Best For | Pros | Cons |
|---|---|---|---|
| pgvector | Production, large datasets | Persistent, scalable, ACID guarantees | Requires PostgreSQL |
| memory | Development, testing, small datasets | Fast, simple setup | Not persistent, limited scale |
| Custom | Cloud-native, managed services | Fully managed, auto-scaling | API costs, vendor lock-in |
Backend Comparison
Storage Capacity
| Backend | Recommended Limit | Notes |
|---|---|---|
| pgvector | 10M+ vectors | Use HNSW index for over 1M vectors |
| memory | Under 100K vectors | Limited by available RAM |
| Pinecone | Unlimited | Paid tiers scale automatically |
Search Performance
- pgvector
- memory
- Custom (Pinecone)
Latency: 10-100ms (depends on index)
Migration Between Backends
Switch from one backend to another:Testing Vector Stores
Best Practices
- Use pgvector for production - Persistent, reliable, and scalable
- Use memory for tests - Fast setup/teardown, isolated state
- Create indexes - Essential for pgvector performance at scale
- Monitor query latency - Attach telemetry handlers
- Tune threshold - Filter low-quality results
- Use collections - Organize vectors by domain/topic
- Batch operations - Insert/update vectors in batches when possible
Troubleshooting
Slow pgvector queries
Slow pgvector queries
Create an index:Or increase shared_buffers in postgresql.conf:
Memory backend out of memory
Memory backend out of memory
Reduce max_elements or switch to pgvector:
pgvector extension not found
pgvector extension not found
Install pgvector:Or use pgvector Docker image:
Custom backend API errors
Custom backend API errors
Check API credentials and network connectivity:
Next Steps
Embeddings
Configure embedding providers
PDF Parsing
Setup PDF document ingestion