Skip to content

Commit

Permalink
Chore: Set various optimizations to database connection
Browse files Browse the repository at this point in the history
Prefer performance over integrity
  • Loading branch information
marcelveldt committed Jan 19, 2025
1 parent 89bcb59 commit af3a96d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion music_assistant/helpers/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,15 @@ async def setup(self) -> None:
"""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:
Expand Down

0 comments on commit af3a96d

Please sign in to comment.