Skip to content

Commit

Permalink
Fine tune DB settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Bond-009 committed Jan 14, 2023
1 parent 56ef45e commit ab918c6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
12 changes: 11 additions & 1 deletion Emby.Server.Implementations/Data/BaseSqliteRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,16 @@ protected BaseSqliteRepository(ILogger<BaseSqliteRepository> logger)
/// <value>The cache size or null.</value>
protected virtual int? CacheSize => null;

/// <summary>
/// Gets the locking mode. <see href="https://www.sqlite.org/pragma.html#pragma_locking_mode" />.
/// </summary>
protected virtual string LockingMode => "EXCLUSIVE";

/// <summary>
/// Gets the journal mode. <see href="https://www.sqlite.org/pragma.html#pragma_journal_mode" />.
/// </summary>
/// <value>The journal mode.</value>
protected virtual string JournalMode => "TRUNCATE";
protected virtual string JournalMode => "WAL";

/// <summary>
/// Gets the page size.
Expand Down Expand Up @@ -116,6 +121,11 @@ protected ManagedConnection GetConnection(bool readOnly = false)
WriteConnection.Execute("PRAGMA cache_size=" + CacheSize.Value);
}

if (!string.IsNullOrWhiteSpace(LockingMode))
{
WriteConnection.Execute("PRAGMA locking_mode=" + LockingMode);
}

if (!string.IsNullOrWhiteSpace(JournalMode))
{
WriteConnection.Execute("PRAGMA journal_mode=" + JournalMode);
Expand Down
2 changes: 0 additions & 2 deletions Emby.Server.Implementations/Data/SqliteItemRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,6 @@ const string CreateMediaAttachmentsTableCommand

string[] queries =
{
"PRAGMA locking_mode=EXCLUSIVE",

"create table if not exists TypedBaseItems (guid GUID primary key NOT NULL, type TEXT NOT NULL, data BLOB NULL, ParentId GUID NULL, Path TEXT NULL)",

"create table if not exists AncestorIds (ItemId GUID NOT NULL, AncestorId GUID NOT NULL, AncestorIdText TEXT NOT NULL, PRIMARY KEY (ItemId, AncestorId))",
Expand Down
4 changes: 0 additions & 4 deletions Jellyfin.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,6 @@ public static void PerformStaticInitialization()
ServicePointManager.Expect100Continue = false;

Batteries_V2.Init();
if (raw.sqlite3_enable_shared_cache(1) != raw.SQLITE_OK)
{
_logger.LogWarning("Failed to enable shared cache for SQLite");
}
}

/// <summary>
Expand Down

0 comments on commit ab918c6

Please sign in to comment.