Search code examples
litedb

Size of a collection in LiteDb


Is it possible to get the size (disk space) of a collection?

I want to limit the size of the database and have a few collections, which grow in size over time. I want to delete older entries if the size of this collection is too large. Similar to a capped collection in mongoDb, but I'm not interested in the high-throughput operations.


Solution

  • In LiteDB it's possible to limit datafile file size, using Limit Size in connection string. This parameter limit growing file size (except journal area). When a document are deleted from any data page, this empty area will be used only this the same collection. If all documents are deleted from a page (4096 bytes) all this page are marked as empty and can be used for any other collection.

    But, this resource are not available by collection, only for all database.