DB Optimizations (#6712)

* Enable auto vacuums

* Enable auto vacuum

* Fix separator

* Fix separator and remove incorrect log

* Limit to 1 row since that is all that is used

* Add index on camera + segment_size

* Formatting

* Increase timeout and cache_size

* Set DB mode to NORMAL synchronous level

* Formatting

* Vacuum every 2 weeks

* Remove fstring

* Use string

* Use consts
This commit is contained in:
Nicolas Mowen
2023-06-11 06:23:18 -06:00
committed by GitHub
parent 20b52a96bc
commit 8bc76d19db
5 changed files with 87 additions and 9 deletions

View File

@@ -37,7 +37,15 @@ def manage_recordings(
setproctitle("frigate.recording_manager")
listen()
db = SqliteQueueDatabase(config.database.path)
db = SqliteQueueDatabase(
config.database.path,
pragmas={
"auto_vacuum": "FULL", # Does not defragment database
"cache_size": -512 * 1000, # 512MB of cache
"synchronous": "NORMAL", # Safe when using WAL https://www.sqlite.org/pragma.html#pragma_synchronous
},
timeout=60,
)
models = [Event, Recordings, Timeline]
db.bind(models)
@@ -48,5 +56,3 @@ def manage_recordings(
cleanup = RecordingCleanup(config, stop_event)
cleanup.start()
logger.info("recording_manager: exiting subprocess")