store() method accepts arrays of records, and for large-scale imports you can partition data into chunks.
Basic Batch Storage
Store multiple records in a single call:TypeScript
Large Dataset Processing
For large datasets, chunk your data into manageable batches:TypeScript
Error Handling in Batches
Retry with Exponential Backoff
TypeScript
Distributed Bulk Operations
When processing large datasets across multiple OnDB client instances (e.g., multiple workers, microservices, or serverless functions), you need coordination for global progress tracking and deduplication.Deduplication with Unique Indexes
Create a unique hash index on a natural key or a dedicatedimport_id field to prevent duplicate records when multiple workers process overlapping data:
Multi-Worker Partitioning
Split work across multiple clients by partitioning the input dataset. Each worker handles a disjoint range:Global Progress Tracking
Use a shared coordination collection to track progress across all workers. Each worker writes its progress, and any client can query the aggregate state:Using Sharding for Distributed Writes
For high-volume distributed ingestion, combine sharding with multi-worker writes so each worker targets a specific shard, avoiding write contention:Concurrency Tuning
When running multiple workers, adjust concurrency based on your needs:| Workers | Use Case |
|---|---|
| 1-3 | Rate-limited APIs, careful processing |
| 5-10 | Standard batch operations |
| 10-20 | High-throughput scenarios |
Next Steps
Sharding
Partition collections for distributed writes
Task Management
Track async operations
Transaction Tracking
Monitor transaction status
Collections & Indexes
Unique indexes for deduplication