Skip to main content
Version: 2.6

Vector Database Performance & Benchmarks

This document addresses performance characteristics, benchmarks, and optimization strategies for Operaide's vector database implementation using libSQL with DiskANN indexing. External developers often have concerns about SQLite-based vector performance—this guide provides concrete metrics and comparisons to address those concerns.

Overview

Operaide uses libSQL with DiskANN (Disk-based Approximate Nearest Neighbor) indexing for vector search. This approach provides enterprise-grade performance while maintaining the simplicity and reliability of SQLite, offering significant advantages over traditional in-memory vector databases.

Key Performance Metrics

Memory Efficiency

MetricDiskANN (libSQL)HNSW (In-Memory)Improvement
1B Vector Memory Usage32 GB512 GB16x less memory
Index Size Reduction8x smaller with compressionBaseline8x space savings
Storage CompressionFloat8 + neighbor optimizationFull precision3-8x reduction

Query Performance

Dataset SizeQPSRecall99th Percentile LatencyMemory Usage
100M vectors10.9399.87%708ms~3.2 GB
1B vectors5-1595%+10-20ms (NVMe SSD)32 GB
Personal scale100+95%+<50ms<1 GB

Indexing Performance

  • Build Time: ~5 hours for 100GB dataset (768-dimensional vectors)
  • Real-time Updates: Thousands of concurrent inserts/deletes per second
  • Index Creation: Scales linearly with dataset size
  • Freshness: Real-time updates without full index rebuilds

Algorithm Foundation: FreshDiskANN

Technical Approach

Operaide's vector implementation is built on FreshDiskANN, a Microsoft Research algorithm that provides:

  1. Graph-based indexing with approximate nearest neighbor search
  2. Real-time updates without compromising search performance
  3. Disk-optimized storage for billion-scale datasets
  4. Low memory footprint compared to in-memory alternatives

Performance Advantages

// Example: Performance characteristics
const performanceProfile = {
memoryUsage: "16x less than HNSW",
queryLatency: "10-20ms for billion-scale",
concurrentOps: "1000+ inserts/deletes per second",
scalability: "Billion+ vectors on single machine",
accuracy: "95%+ recall at 5",
costEfficiency: "5-10x cost reduction vs DRAM-based solutions"
};

Optimization Strategies

1. Vector Compression

-- LibSQL supports multiple compression formats
CREATE INDEX vectors_idx ON vectors (
libsql_vector_idx(vector,
'compress=float8', -- 3x size reduction
'neighbors=20' -- 8x total reduction when combined
)
);

Compression Options:

  • Float16: 2x space reduction, minimal accuracy loss
  • Float8: 3x space reduction, good accuracy retention
  • Int8: 4x space reduction, requires quantization
  • 1-bit: Maximum compression, specialized embeddings needed

2. Neighbor Configuration

-- Optimize neighbor count for your use case
CREATE INDEX vectors_idx ON vectors (
libsql_vector_idx(vector,
'neighbors=20' -- vs default 70 (3 * sqrt(vector_length))
)
);

Configuration Guidelines:

  • Default: 70 neighbors for maximum accuracy
  • Optimized: 20 neighbors for 8x space reduction
  • Personal scale: 10-15 neighbors sufficient for <1M vectors
  • Enterprise scale: 30-50 neighbors for >100M vectors

3. Query Optimization

// Optimized vector search pattern
const searchResults = await aktorVektorRetrievalPipeline({
client: dbClient,
query: searchTerm,
limit: 10, // Limit results for better performance
vectorSearchStrategy: customDiskANNStrategy,
metadataFilterStrategy: preFilterStrategy // Filter before vector search
});

Performance Comparisons

vs. Traditional Vector Databases

SystemMemory (1B vectors)Query LatencyCostMaintenance
libSQL/DiskANN32 GB10-20msLowMinimal
PineconeVariable5-15msHighManaged
Weaviate200+ GB5-10msMediumSelf-hosted
FAISS (HNSW)512 GB<5msVery HighComplex
Qdrant100+ GB8-15msMediumSelf-hosted

vs. In-Memory Solutions

Real-World Performance

Small to Medium Scale (1K - 1M documents)

const performanceProfile = {
indexSize: "5-50 MB",
memoryUsage: "10-100 MB",
queryLatency: "<10ms",
throughput: "500+ QPS",
accuracy: "98%+ recall"
};

Large Scale (1M - 100M documents)

const performanceProfile = {
indexSize: "500MB - 5GB",
memoryUsage: "1-10 GB",
queryLatency: "10-50ms",
throughput: "100+ QPS",
accuracy: "95%+ recall"
};

Enterprise Scale (100M+ documents)

const performanceProfile = {
indexSize: "5GB+",
memoryUsage: "10-50 GB",
queryLatency: "20-100ms",
throughput: "50+ QPS",
accuracy: "95%+ recall"
};

Performance Tuning Guidelines

1. Hardware Recommendations

Minimum Requirements:

  • CPU: 4+ cores
  • RAM: 8GB+ (scales with dataset)
  • Storage: SSD required for production workloads
  • Network: Low latency for distributed deployments

Optimal Configuration:

  • CPU: 8+ cores with high single-thread performance
  • RAM: 16GB+ for caching and concurrent operations
  • Storage: NVMe SSD for <20ms query latency
  • Network: <10ms latency between replicas

2. Configuration Optimization

// Optimized embedding pipeline configuration
const optimizedConfig = {
chunkingStrategy: {
chunkSize: 512, // Optimal for most embedding models
overlap: 0.1, // Minimal overlap for performance
batchSize: 100 // Batch processing for efficiency
},
embeddingStrategy: {
batchSize: 50, // API rate limit optimization
dimensions: 768, // Balance accuracy vs storage
model: "text-embedding-3-small" // Cost-optimized
},
vectorIndexing: {
compression: "float8", // 3x space reduction
neighbors: 20, // 8x reduction when combined
buildThreads: 4 // Parallel index construction
}
};

3. Query Optimization

-- Optimized vector search with pre-filtering
SELECT chunk_id, content, similarity
FROM (
SELECT chunk_id, content,
libsql_vector_distance_cos(vector, ?) as similarity
FROM vectors
WHERE chunk_id IN (
SELECT chunk_id FROM chunks
WHERE metadata->>'type' = 'technical_doc' -- Pre-filter
)
ORDER BY similarity DESC
LIMIT 10
) ranked_results
WHERE similarity > 0.7; -- Post-filter for quality

Monitoring & Troubleshooting

Performance Metrics to Track

interface VectorDBMetrics {
queryLatency: {
p50: number; // 50th percentile
p95: number; // 95th percentile
p99: number; // 99th percentile
};
throughput: {
qps: number; // Queries per second
insertRate: number; // Documents per second
indexingRate: number; // Chunks per second
};
resources: {
memoryUsage: number; // MB
diskUsage: number; // MB
cpuUtilization: number; // Percentage
};
accuracy: {
recall: number; // Retrieval accuracy
precision: number; // Result relevance
};
}

Common Performance Issues

IssueSymptomsSolution
High query latency>100ms response timesCheck SSD performance, reduce neighbors
Low recallPoor search resultsIncrease neighbors, check embedding quality
Memory pressureOOM errorsEnable compression, reduce batch sizes
Index bloatLarge disk usageOptimize compression, regular maintenance

Best Practices

1. Index Maintenance

// Regular index optimization
const maintenanceSchedule = {
daily: "VACUUM; ANALYZE;", // SQLite optimization
weekly: "REINDEX vectors_idx;", // Index rebuild
monthly: "Full backup and restore" // Complete refresh
};

2. Batch Operations

// Efficient batch processing
const batchProcessor = {
insertBatchSize: 100, // Optimal for most workloads
embeddingBatchSize: 50, // API rate limit consideration
commitInterval: 1000 // Transaction optimization
};

3. Monitoring Integration

// Performance monitoring integration
import { metrics } from '@operaide/vector';

const performanceMonitor = {
logSlowQueries: true, // >100ms queries
trackMemoryUsage: true, // Memory pressure alerts
alertOnHighLatency: true, // >500ms alerts
collectMetrics: 'hourly' // Aggregation frequency
};

Conclusion

libSQL with DiskANN provides enterprise-grade vector search performance while maintaining SQLite's simplicity and reliability. Key advantages include:

  • 16x memory efficiency compared to in-memory solutions
  • Billion-scale capability on single machines
  • Real-time updates without index rebuilds
  • Cost-effective scaling with predictable performance
  • Simple deployment with SQLite compatibility

For most applications, this architecture provides optimal balance of performance, cost, and operational simplicity, making it ideal for production vector search workloads.

References