Use Appropriate topK
Request only as many results as you need:src/performance-topk.ts
Use Filters to Reduce Search Space
Apply metadata filters to narrow results:src/performance-filters.ts
Enable HNSW for Large Datasets
For datasets > 10,000 documents, enable HNSW indexing:src/performance-hnsw.ts
Performance Comparison
| Documents | Brute-force | HNSW (ef=50) |
|---|---|---|
| 10,000 | ~50ms | ~1ms |
| 50,000 | ~250ms | ~1ms |
| 100,000 | ~500ms | ~2ms |
Query Caching
Cache frequent queries for better performance:src/query-caching.ts
Warmup Queries
Run a warmup query during startup to optimize the embedding pipeline:src/warmup.ts
Batch Similar Queries
If you need to run multiple searches with the same query:src/batch-queries.ts
Monitoring Search Performance
src/performance-monitoring.ts
Performance Checklist
Related
HNSW Overview
Scale with HNSW
HNSW Tuning
Tune HNSW parameters
Basic Search
Search fundamentals