mbdavid / LiteDB

LiteDB - A .NET NoSQL Document Store in a single data file
http://www.litedb.org
MIT License
8.62k stars 1.25k forks source link

[QUESTION] Is there a way to determine whether DB rebuild is necessary? #2396

Open lanopk opened 11 months ago

lanopk commented 11 months ago

Is there a way to determine whether DB rebuild is necessary? If the DB file is very large, rebuilding it takes a lot of time.

After performing many operations such as insert, delete, and update, How can I decide if I need to rebuild or if I should continue using it?

It would be nice to be able to determine whether a lot of fragments occurred.

AlainGhawi commented 11 months ago

I faced the corruption of the LiteDB after a high number of inserts.

What I would recommend if you ever face a System.Exception with the message starting with LiteDB ENSURE: rebuild the database as it will fix it in the majority of times.