github TanStack/db @tanstack/db@0.4.19

latest releases: @tanstack/trailbase-db-collection@0.1.43, @tanstack/powersync-db-collection@0.1.2, @tanstack/solid-db@0.1.41...
23 hours ago

Patch Changes

  • Significantly improve localStorage collection performance during rapid mutations (#760)

    Optimizes localStorage collections to eliminate redundant storage reads, providing dramatic performance improvements for use cases with rapid mutations (e.g., text input with live query rendering).

    Performance Improvements:

    • 67% reduction in localStorage I/O operations - from 3 reads + 1 write per mutation down to just 1 write
    • Eliminated 2 JSON parse operations per mutation
    • Eliminated 1 full collection diff operation per mutation
    • Leverages in-memory cache (lastKnownData) instead of reading from storage on every mutation

    What Changed:

    1. Mutation handlers now use in-memory cache instead of loading from storage before mutations
    2. Post-mutation sync eliminated - no longer triggers redundant storage reads after local mutations
    3. Manual transactions (acceptMutations) optimized to use in-memory cache

    Before: Each mutation performed 3 I/O operations:

    • loadFromStorage() - read + JSON parse
    • Modify data
    • saveToStorage() - JSON stringify + write
    • processStorageChanges() - another read + parse + diff

    After: Each mutation performs 1 I/O operation:

    • Modify in-memory data ✨ No I/O!
    • saveToStorage() - JSON stringify + write

    Safety:

    • Cross-tab synchronization still works correctly via storage event listeners
    • All 50 tests pass including 8 new tests specifically for rapid mutations and edge cases
    • 92.3% code coverage on local-storage.ts
    • lastKnownData cache kept in sync with storage through initial load, mutations, and cross-tab events

    This optimization is particularly impactful for applications with:

    • Real-time text input with live query rendering
    • Frequent mutations to localStorage-backed collections
    • Multiple rapid sequential mutations

Don't miss a new db release

NewReleases is sending notifications on new releases.