0

Working on an embedded c++ system that has very limited memory. I need to lock the database file to 10MB. Is there a good way to do this?

Currently we attempted to get the file size and determine if data needed to be deleted. The file size doesn't actually change. Looking at some other documentation I would need to copy it and rebuild the database to reduce the size. The system doesn't have space to copy over the file.

Frant
  • 5,382
  • 1
  • 16
  • 22
  • 1
    Does this answer your question? [how to shrink sqlite database?](https://stackoverflow.com/questions/7682503/how-to-shrink-sqlite-database) – Botje Aug 03 '20 at 14:25
  • @Botje The main issue with VACUUM is that it creates a copy of the .db file. The system doesnt have the memory to do that. That would mean I would need to cut the allowed space for the database in half. – Kevin Lucas Aug 03 '20 at 14:28
  • 1
    Have you tried turning on the auto_vacuum mode as suggested in the answer? SQLite does not have an in-place vacuum, as that would compromise its resilience against crashes. – Botje Aug 03 '20 at 14:31
  • 1
    Maybe also [https://sqlite.org/pragma.html#pragma_max_page_count](https://sqlite.org/pragma.html#pragma_max_page_count) – drescherjm Aug 03 '20 at 14:32
  • @Botje I will need to try this. I was unaware that the auto-vacuum worked differently then the regular vacuum command. – Kevin Lucas Aug 03 '20 at 14:38
  • 1
    There are different modes described here: [https://sqlite.org/pragma.html#pragma_auto_vacuum](https://sqlite.org/pragma.html#pragma_auto_vacuum) – drescherjm Aug 03 '20 at 14:39

0 Answers0