aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Data/BaseSqliteRepository.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-11-21 03:54:53 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-11-21 03:54:53 -0500
commitf275d7f3d2f40f5e4cbe2f97df6dbd9be8ec37fe (patch)
tree44d15fc67ebe2b131e77531cd7e14c33bd695370 /Emby.Server.Implementations/Data/BaseSqliteRepository.cs
parent1dc080df8ba5b9af9245788634d56cb155afd2ba (diff)
reduce library queries
Diffstat (limited to 'Emby.Server.Implementations/Data/BaseSqliteRepository.cs')
-rw-r--r--Emby.Server.Implementations/Data/BaseSqliteRepository.cs37
1 files changed, 29 insertions, 8 deletions
diff --git a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs
index 382c7f245..d4226ec25 100644
--- a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs
+++ b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs
@@ -40,6 +40,8 @@ namespace Emby.Server.Implementations.Data
private static bool _versionLogged;
+ private string _defaultWal;
+
protected SQLiteDatabaseConnection CreateConnection(bool isReadOnly = false, Action<SQLiteDatabaseConnection> onConnect = null)
{
if (!_versionLogged)
@@ -51,6 +53,15 @@ namespace Emby.Server.Implementations.Data
ConnectionFlags connectionFlags;
+ if (isReadOnly)
+ {
+ //Logger.Info("Opening read connection");
+ }
+ else
+ {
+ //Logger.Info("Opening write connection");
+ }
+
isReadOnly = false;
if (isReadOnly)
@@ -70,12 +81,16 @@ namespace Emby.Server.Implementations.Data
var db = SQLite3.Open(DbFilePath, connectionFlags, null);
+ if (string.IsNullOrWhiteSpace(_defaultWal))
+ {
+ _defaultWal = db.Query("PRAGMA journal_mode").SelectScalarString().First();
+ }
+
var queries = new List<string>
{
+ "PRAGMA default_temp_store=memory",
"pragma temp_store = memory",
- "PRAGMA page_size=4096",
- "PRAGMA journal_mode=WAL",
- "pragma synchronous=Normal",
+ "PRAGMA journal_mode=WAL"
//"PRAGMA cache size=-10000"
};
@@ -90,13 +105,19 @@ namespace Emby.Server.Implementations.Data
//// db.Execute(query);
////}
- using (WriteLock.Write())
- {
- db.ExecuteAll(string.Join(";", queries.ToArray()));
+ //Logger.Info("synchronous: " + db.Query("PRAGMA synchronous").SelectScalarString().First());
+ //Logger.Info("temp_store: " + db.Query("PRAGMA temp_store").SelectScalarString().First());
- if (onConnect != null)
+ //if (!string.Equals(_defaultWal, "wal", StringComparison.OrdinalIgnoreCase) || onConnect != null)
+ {
+ using (WriteLock.Write())
{
- onConnect(db);
+ db.ExecuteAll(string.Join(";", queries.ToArray()));
+
+ if (onConnect != null)
+ {
+ onConnect(db);
+ }
}
}