Vector Database Configurations
Provides comprehensive configuration, setup scripts, and templates for six popular vector databases used in RAG pipelines. Includes database selection guide, functional setup scripts, configuration templates, and migration examples.
Use When
- Setting up vector storage for RAG pipeline
- Comparing vector database options for a project
- Migrating between vector databases
- Configuring vector indexes and schema
- Optimizing vector search performance
- Setting up development or production vector databases
- Generating database-specific configuration files
Vector Database Comparison
Quick Selection Guide
pgvector (PostgreSQL extension)
- Best for: Existing PostgreSQL users, transactional consistency, complex filtering
- Hosting: Self-hosted, managed Postgres (Supabase, RDS, etc.)
- Scale: Up to millions of vectors with proper indexing
- Cost: Free (open source), hosting costs only
- When to use: You already use PostgreSQL, need ACID guarantees, complex metadata queries
Chroma
- Best for: Development, prototyping, local-first applications
- Hosting: In-process, client-server, or cloud
- Scale: Thousands to millions of vectors
- Cost: Free (open source), cloud pricing for hosted
- When to use: Fast prototyping, embedded applications, simple deployments
Pinecone
- Best for: Production deployments, managed service, high performance
- Hosting: Fully managed cloud only
- Scale: Billions of vectors
- Cost: Paid service with free tier
- When to use: Production systems, need managed infrastructure, high scale
Weaviate
- Best for: GraphQL APIs, semantic search, hybrid search
- Hosting: Self-hosted or cloud
- Scale: Billions of vectors
- Cost: Free (open source), cloud pricing for managed
- When to use: Need GraphQL interface, hybrid keyword+vector search, modules ecosystem
Qdrant
- Best for: High performance, filtering, payload indexing
- Hosting: Self-hosted, Docker, or cloud
- Scale: Billions of vectors
- Cost: Free (open source), cloud pricing for managed
- When to use: Need advanced filtering, high-performance search, Rust performance
FAISS
- Best for: Research, maximum performance, custom algorithms
- Hosting: Self-managed in application
- Scale: Billions of vectors (with proper hardware)
- Cost: Free (open source)
- When to use: Maximum performance, custom algorithms, research projects, batch processing
Feature Comparison
| Feature |
pgvector |
Chroma |
Pinecone |
Weaviate |
Qdrant |
FAISS |
| Setup Complexity |
Medium |
Low |
Low |
Medium |
Medium |
High |
| Distance Metrics |
L2, Cosine, Inner Product |
L2, Cosine, IP |
Cosine, Euclidean, Dot |
Multiple |
Multiple |
Multiple |
| Metadata Filtering |
Excellent (SQL) |
Good |
Good |
Excellent (GraphQL) |
Excellent |
Manual |
| ACID Transactions |
Yes |
No |
No |
No |
No |
No |
| Horizontal Scaling |
Limited |
Yes |
Yes |
Yes |
Yes |
Manual |
| Cloud Managed |
Via providers |
Yes |
Yes (only) |
Yes |
Yes |
No |
| Open Source |
Yes |
Yes |
No |
Yes |
Yes |
Yes |
Available Scripts
All scripts are located in scripts/ directory and are fully functional:
setup-pgvector.sh
- Installs pgvector extension
- Creates database and enables extension
- Sets up vector schema with indexes
- Configures optimal settings
setup-chroma.sh
- Installs Chroma via pip
- Initializes persistent client
- Creates collections
- Configures embedding functions
setup-pinecone.sh
- Validates API key
- Creates indexes with specified dimensions
- Configures metadata indexes
- Sets up serverless or pod-based deployment
setup-weaviate.sh
- Starts Weaviate with Docker
- Creates schema classes
- Configures vectorizer modules
- Sets up GraphQL endpoint
setup-qdrant.sh
- Starts Qdrant with Docker or installs client
- Creates collections
- Configures vector and payload indexes
- Sets up API endpoints
setup-faiss.sh
- Installs FAISS via conda or pip
- Creates index with specified algorithm
- Configures search parameters
- Sets up serialization
Available Templates
All templates are located in templates/ directory:
pgvector-schema.sql
- Vector column definitions
- Index creation (IVFFlat, HNSW)
- Distance function examples
- Optimized search queries
chroma-config.py
- Client initialization
- Collection setup
- Embedding configuration
- Query patterns
pinecone-config.py
- API authentication
- Index creation
- Upsert and query examples
- Metadata filtering
weaviate-schema.py
- Schema class definition
- Vector configuration
- Module setup
- GraphQL queries
qdrant-config.py
- Collection creation
- Vector and payload config
- Search API examples
- Filter queries
faiss-config.py
- Index factory patterns
- Training and adding vectors
- Search configuration
- Serialization helpers
Available Examples
Located in examples/ directory:
migration-guide.md
- Migration paths between databases
- Data export/import scripts
- Schema mapping examples
- Testing migration accuracy
performance-tuning.md
- Index optimization for each database
- Query performance tips
- Batch operation patterns
- Monitoring and metrics
Usage Examples
Compare Databases for Project
Read SKILL.md comparison table and selection guide to choose the right database based on:
- Existing infrastructure (PostgreSQL → pgvector)
- Scale requirements (Billions → Pinecone, Qdrant, Weaviate)
- Hosting preference (Managed → Pinecone, Self-hosted → others)
- Budget constraints (Free tier needed → Chroma, pgvector, FAISS)
- Feature requirements (GraphQL → Weaviate, Advanced filtering → Qdrant)
Setup pgvector on Existing PostgreSQL
# Run setup script
bash scripts/setup-pgvector.sh --database mydb --user postgres --dimensions 1536
# Apply schema template
psql -U postgres -d mydb -f templates/pgvector-schema.sql
Setup Chroma for Development
# Install and configure
bash scripts/setup-chroma.sh --persist-dir ./chroma_data --collection documents
# Use Python configuration template
cp templates/chroma-config.py ./config/vector_db.py
Setup Pinecone for Production
# Configure with API key
export PINECONE_API_KEY="your-key"
bash scripts/setup-pinecone.sh --index production-docs --dimensions 1536 --metric cosine
# Use configuration template
cp templates/pinecone-config.py ./config/vector_db.py
Migrate from Chroma to Qdrant
# Export from Chroma
python examples/migration-scripts/export-chroma.py --output vectors.json
# Setup Qdrant
bash scripts/setup-qdrant.sh --collection documents --dimensions 1536
# Import to Qdrant
python examples/migration-scripts/import-qdrant.py --input vectors.json
Integration with RAG Pipeline
This skill integrates with other rag-pipeline components:
document-chunking skill → Generates chunks to be embedded
embedding-models skill → Generates vectors to be stored
vector-database-configs → Stores and retrieves vectors
retrieval-strategies skill → Queries vector database
Distance Metrics Guide
Cosine Similarity
- Range: -1 to 1 (higher is more similar)
- Best for: Text embeddings (OpenAI, Cohere, etc.)
- Normalized: Yes (magnitude independent)
Euclidean (L2)
- Range: 0 to infinity (lower is more similar)
- Best for: Image embeddings, spatial data
- Normalized: No (affected by magnitude)
Inner Product (Dot Product)
- Range: -infinity to infinity (higher is more similar)
- Best for: When embeddings are normalized
- Normalized: Depends on vectors
Performance Optimization Tips
For All Databases:
- Use appropriate index type for scale (HNSW for large datasets)
- Batch insert operations
- Monitor query latency and adjust index parameters
- Pre-filter on metadata before vector search when possible
pgvector Specific:
- Use
ivfflat for 100K-1M vectors, hnsw for 1M+
- Increase
maintenance_work_mem for index building
- Use partial indexes for filtered queries
- Consider table partitioning for very large datasets
FAISS Specific:
- Choose index based on dataset size (Flat < 10K, IVF < 100M, HNSW for most)
- Use GPU indices for maximum performance
- Pre-train IVF indices with representative data
- Adjust nprobe parameter for accuracy/speed tradeoff
Error Handling
All scripts include:
- Dependency checking before execution
- Connection validation
- Clear error messages with resolution steps
- Rollback on failure where applicable
- Environment variable validation
Security Considerations
- Store API keys in environment variables (never hardcode)
- Use connection pooling for database connections
- Enable TLS/SSL for network connections
- Implement authentication for self-hosted deployments
- Use read-only credentials for query-only applications
- Sanitize user inputs before using in filters
References
1---2name: vector-database-configs3description: Vector database configuration and setup for pgvector, Chroma, Pinecone, Weaviate, Qdrant, and FAISS with comparison guide and migration helpers4---5
6# Vector Database Configurations
7
8Provides comprehensive configuration, setup scripts, and templates for six popular vector databases used in RAG pipelines. Includes database selection guide, functional setup scripts, configuration templates, and migration examples.
9
10## Use When
11
12- Setting up vector storage for RAG pipeline
13- Comparing vector database options for a project
14- Migrating between vector databases
15- Configuring vector indexes and schema
16- Optimizing vector search performance
17- Setting up development or production vector databases
18- Generating database-specific configuration files
19
20## Vector Database Comparison
21
22### Quick Selection Guide
23
24**pgvector (PostgreSQL extension)**
25- Best for: Existing PostgreSQL users, transactional consistency, complex filtering
26- Hosting: Self-hosted, managed Postgres (Supabase, RDS, etc.)
27- Scale: Up to millions of vectors with proper indexing
28- Cost: Free (open source), hosting costs only
29- When to use: You already use PostgreSQL, need ACID guarantees, complex metadata queries
30
31**Chroma**
32- Best for: Development, prototyping, local-first applications
33- Hosting: In-process, client-server, or cloud
34- Scale: Thousands to millions of vectors
35- Cost: Free (open source), cloud pricing for hosted
36- When to use: Fast prototyping, embedded applications, simple deployments
37
38**Pinecone**
39- Best for: Production deployments, managed service, high performance
40- Hosting: Fully managed cloud only
41- Scale: Billions of vectors
42- Cost: Paid service with free tier
43- When to use: Production systems, need managed infrastructure, high scale
44
45**Weaviate**
46- Best for: GraphQL APIs, semantic search, hybrid search
47- Hosting: Self-hosted or cloud
48- Scale: Billions of vectors
49- Cost: Free (open source), cloud pricing for managed
50- When to use: Need GraphQL interface, hybrid keyword+vector search, modules ecosystem
51
52**Qdrant**
53- Best for: High performance, filtering, payload indexing
54- Hosting: Self-hosted, Docker, or cloud
55- Scale: Billions of vectors
56- Cost: Free (open source), cloud pricing for managed
57- When to use: Need advanced filtering, high-performance search, Rust performance
58
59**FAISS**
60- Best for: Research, maximum performance, custom algorithms
61- Hosting: Self-managed in application
62- Scale: Billions of vectors (with proper hardware)
63- Cost: Free (open source)
64- When to use: Maximum performance, custom algorithms, research projects, batch processing
65
66### Feature Comparison
67
68| Feature | pgvector | Chroma | Pinecone | Weaviate | Qdrant | FAISS |
69|---------|----------|--------|----------|----------|--------|-------|
70| Setup Complexity | Medium | Low | Low | Medium | Medium | High |
71| Distance Metrics | L2, Cosine, Inner Product | L2, Cosine, IP | Cosine, Euclidean, Dot | Multiple | Multiple | Multiple |
72| Metadata Filtering | Excellent (SQL) | Good | Good | Excellent (GraphQL) | Excellent | Manual |
73| ACID Transactions | Yes | No | No | No | No | No |
74| Horizontal Scaling | Limited | Yes | Yes | Yes | Yes | Manual |
75| Cloud Managed | Via providers | Yes | Yes (only) | Yes | Yes | No |
76| Open Source | Yes | Yes | No | Yes | Yes | Yes |
77
78## Available Scripts
79
80All scripts are located in `scripts/` directory and are fully functional:
81
82**setup-pgvector.sh**
83- Installs pgvector extension
84- Creates database and enables extension
85- Sets up vector schema with indexes
86- Configures optimal settings
87
88**setup-chroma.sh**
89- Installs Chroma via pip
90- Initializes persistent client
91- Creates collections
92- Configures embedding functions
93
94**setup-pinecone.sh**
95- Validates API key
96- Creates indexes with specified dimensions
97- Configures metadata indexes
98- Sets up serverless or pod-based deployment
99
100**setup-weaviate.sh**
101- Starts Weaviate with Docker
102- Creates schema classes
103- Configures vectorizer modules
104- Sets up GraphQL endpoint
105
106**setup-qdrant.sh**
107- Starts Qdrant with Docker or installs client
108- Creates collections
109- Configures vector and payload indexes
110- Sets up API endpoints
111
112**setup-faiss.sh**
113- Installs FAISS via conda or pip
114- Creates index with specified algorithm
115- Configures search parameters
116- Sets up serialization
117
118## Available Templates
119
120All templates are located in `templates/` directory:
121
122**pgvector-schema.sql**
123- Vector column definitions
124- Index creation (IVFFlat, HNSW)
125- Distance function examples
126- Optimized search queries
127
128**chroma-config.py**
129- Client initialization
130- Collection setup
131- Embedding configuration
132- Query patterns
133
134**pinecone-config.py**
135- API authentication
136- Index creation
137- Upsert and query examples
138- Metadata filtering
139
140**weaviate-schema.py**
141- Schema class definition
142- Vector configuration
143- Module setup
144- GraphQL queries
145
146**qdrant-config.py**
147- Collection creation
148- Vector and payload config
149- Search API examples
150- Filter queries
151
152**faiss-config.py**
153- Index factory patterns
154- Training and adding vectors
155- Search configuration
156- Serialization helpers
157
158## Available Examples
159
160Located in `examples/` directory:
161
162**migration-guide.md**
163- Migration paths between databases
164- Data export/import scripts
165- Schema mapping examples
166- Testing migration accuracy
167
168**performance-tuning.md**
169- Index optimization for each database
170- Query performance tips
171- Batch operation patterns
172- Monitoring and metrics
173
174## Usage Examples
175
176### Compare Databases for Project
177
178Read SKILL.md comparison table and selection guide to choose the right database based on:
179- Existing infrastructure (PostgreSQL → pgvector)
180- Scale requirements (Billions → Pinecone, Qdrant, Weaviate)
181- Hosting preference (Managed → Pinecone, Self-hosted → others)
182- Budget constraints (Free tier needed → Chroma, pgvector, FAISS)
183- Feature requirements (GraphQL → Weaviate, Advanced filtering → Qdrant)
184
185### Setup pgvector on Existing PostgreSQL
186
187```bash
188# Run setup script
189bash scripts/setup-pgvector.sh --database mydb --user postgres --dimensions 1536
190
191# Apply schema template
192psql -U postgres -d mydb -f templates/pgvector-schema.sql
193```
194
195### Setup Chroma for Development
196
197```bash
198# Install and configure
199bash scripts/setup-chroma.sh --persist-dir ./chroma_data --collection documents
200
201# Use Python configuration template
202cp templates/chroma-config.py ./config/vector_db.py
203```
204
205### Setup Pinecone for Production
206
207```bash
208# Configure with API key
209export PINECONE_API_KEY="your-key"
210bash scripts/setup-pinecone.sh --index production-docs --dimensions 1536 --metric cosine
211
212# Use configuration template
213cp templates/pinecone-config.py ./config/vector_db.py
214```
215
216### Migrate from Chroma to Qdrant
217
218```bash
219# Export from Chroma
220python examples/migration-scripts/export-chroma.py --output vectors.json
221
222# Setup Qdrant
223bash scripts/setup-qdrant.sh --collection documents --dimensions 1536
224
225# Import to Qdrant
226python examples/migration-scripts/import-qdrant.py --input vectors.json
227```
228
229## Integration with RAG Pipeline
230
231This skill integrates with other rag-pipeline components:
232
233**document-chunking skill** → Generates chunks to be embedded
234**embedding-models skill** → Generates vectors to be stored
235**vector-database-configs** → Stores and retrieves vectors
236**retrieval-strategies skill** → Queries vector database
237
238## Distance Metrics Guide
239
240**Cosine Similarity**
241- Range: -1 to 1 (higher is more similar)
242- Best for: Text embeddings (OpenAI, Cohere, etc.)
243- Normalized: Yes (magnitude independent)
244
245**Euclidean (L2)**
246- Range: 0 to infinity (lower is more similar)
247- Best for: Image embeddings, spatial data
248- Normalized: No (affected by magnitude)
249
250**Inner Product (Dot Product)**
251- Range: -infinity to infinity (higher is more similar)
252- Best for: When embeddings are normalized
253- Normalized: Depends on vectors
254
255## Performance Optimization Tips
256
257**For All Databases:**
258- Use appropriate index type for scale (HNSW for large datasets)
259- Batch insert operations
260- Monitor query latency and adjust index parameters
261- Pre-filter on metadata before vector search when possible
262
263**pgvector Specific:**
264- Use `ivfflat` for 100K-1M vectors, `hnsw` for 1M+
265- Increase `maintenance_work_mem` for index building
266- Use partial indexes for filtered queries
267- Consider table partitioning for very large datasets
268
269**FAISS Specific:**
270- Choose index based on dataset size (Flat < 10K, IVF < 100M, HNSW for most)
271- Use GPU indices for maximum performance
272- Pre-train IVF indices with representative data
273- Adjust nprobe parameter for accuracy/speed tradeoff
274
275## Error Handling
276
277All scripts include:
278- Dependency checking before execution
279- Connection validation
280- Clear error messages with resolution steps
281- Rollback on failure where applicable
282- Environment variable validation
283
284## Security Considerations
285
286- Store API keys in environment variables (never hardcode)
287- Use connection pooling for database connections
288- Enable TLS/SSL for network connections
289- Implement authentication for self-hosted deployments
290- Use read-only credentials for query-only applications
291- Sanitize user inputs before using in filters
292
293## References
294
295- pgvector: https://github.com/pgvector/pgvector
296- Supabase pgvector: https://supabase.com/docs/guides/ai/vector-columns
297- Chroma: https://docs.trychroma.com/
298- Pinecone: https://docs.pinecone.io/
299- Weaviate: https://weaviate.io/developers/weaviate
300- Qdrant: https://qdrant.tech/documentation/
301- FAISS: https://faiss.ai/