Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete all records take a long time #389

Closed
ZihaoGuan opened this issue Sep 5, 2024 · 1 comment
Closed

Delete all records take a long time #389

ZihaoGuan opened this issue Sep 5, 2024 · 1 comment

Comments

@ZihaoGuan
Copy link

Hi,

We want to clear the data when user logs out, and we notice that it would take a long time to perform record deletions for 5 different store in the same database.

Delete record count: 67916
Elapsed time: 44 s

Any suggestion to improve?

@alextekartik
Copy link
Collaborator

My guest is that you are using databaseFactoryIo which uses an append only file format. Deletion tends to trigger a compact operation which is extensive (rewriting the new file).

The first thing to try would be to do all the deletions in a single transaction so that only 1 compact operation happens.

But my recommendation would be to use the factory from sembast_sqflite since this compact operation does not happen so it should be much faster. The API is the same, it is only a matter of having a different factory to open the database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants