From af3a96d7daf3b91272b1b6fb7639f1df91965c2c Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Sun, 19 Jan 2025 21:37:32 +0100 Subject: [PATCH] Chore: Set various optimizations to database connection Prefer performance over integrity --- music_assistant/helpers/database.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/music_assistant/helpers/database.py b/music_assistant/helpers/database.py index 9e0e37e1..8d1cf2b1 100644 --- a/music_assistant/helpers/database.py +++ b/music_assistant/helpers/database.py @@ -80,8 +80,15 @@ class DatabaseConnection: """Perform async initialization.""" self._db = await aiosqlite.connect(self.db_path) self._db.row_factory = aiosqlite.Row + # setup some default settings for more performance await self.execute("PRAGMA analysis_limit=10000;") - await self.execute("PRAGMA optimize;") + await self.execute("PRAGMA locking_mode=exclusive;") + await self.execute("PRAGMA journal_mode=WAL;") + await self.execute("PRAGMA journal_size_limit = 6144000;") + await self.execute("PRAGMA synchronous=normal;") + await self.execute("PRAGMA temp_store=memory;") + await self.execute("PRAGMA mmap_size = 30000000000;") + await self.execute("PRAGMA cache_size = -64000;") await self.commit() async def close(self) -> None: -- 2.34.1