Skip to content

Commit

Permalink
indexeddb: Clear the object store before deleting it
Browse files Browse the repository at this point in the history
Since my investigation found that it significantly speeds up deletion of
a store on both Firefox and Chromium if you clear() it first, do that in
our migration code.
  • Loading branch information
andybalaam committed Feb 2, 2024
1 parent 40e0066 commit 916e85f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/matrix-sdk-indexeddb/src/crypto_store/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ async fn prepare_data_for_v7(serializer: &IndexeddbSerializer, db: &IdbDatabase)
}
}

// We have finished with the old store. Clear it, since it is faster to
// clear+delete than just delete. See https://www.artificialworlds.net/blog/2024/02/01/deleting-an-indexed-db-store-can-be-incredibly-slow-on-firefox/
// for more details.
old_store.clear()?.await?;

Ok(txn.await.into_result()?)
}

Expand Down

0 comments on commit 916e85f

Please sign in to comment.