Was trying to see which method for bulk retrieving data from IndexedDB would perform the best on different data distribution.
- Use
Promise.all(keys.map(key => store.get(key)))for most cases (random lookups or even contigiuos-ish cases are mostly fine). - Use
store.get(KeyRange.bound(lower, upper)when you know you are interested in a contigious range. - Avoid cursor API whenever possible. If you are fine with a bit more memory usage, just fetch everything via
getAll()and do filtering afterwards. - The chunked retrieval is honestly pretty descent, for contigious/contigiuos-ish lookups.
- When the loads start to look like full-table retrieval (ie. retrieving 80% of the records),
Promise.allstarts to fall behind. Consider doing full-table retrieval, or, if you are memory constrained, chunked iteration/full-table scan viagetAllor cursor API.
Duh.