update connection pooling
This commit is contained in:
parent
96b1ddfddf
commit
da6e94396f
|
@ -33,7 +33,7 @@ namespace MediaBrowser.Controller.Chapters
|
|||
/// <param name="chapters">The chapters.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SaveChapters(string itemId, IEnumerable<ChapterInfo> chapters, CancellationToken cancellationToken);
|
||||
Task SaveChapters(string itemId, List<ChapterInfo> chapters, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Searches the specified video.
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace MediaBrowser.Controller.Persistence
|
|||
/// <param name="chapters">The chapters.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SaveChapters(Guid id, IEnumerable<ChapterInfo> chapters, CancellationToken cancellationToken);
|
||||
Task SaveChapters(Guid id, List<ChapterInfo> chapters, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the media streams.
|
||||
|
@ -97,7 +97,7 @@ namespace MediaBrowser.Controller.Persistence
|
|||
/// <param name="streams">The streams.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SaveMediaStreams(Guid id, IEnumerable<MediaStream> streams, CancellationToken cancellationToken);
|
||||
Task SaveMediaStreams(Guid id, List<MediaStream> streams, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the item ids.
|
||||
|
|
|
@ -259,7 +259,7 @@ namespace MediaBrowser.Providers.Chapters
|
|||
return _itemRepo.GetChapters(new Guid(itemId));
|
||||
}
|
||||
|
||||
public Task SaveChapters(string itemId, IEnumerable<ChapterInfo> chapters, CancellationToken cancellationToken)
|
||||
public Task SaveChapters(string itemId, List<ChapterInfo> chapters, CancellationToken cancellationToken)
|
||||
{
|
||||
return _itemRepo.SaveChapters(new Guid(itemId), chapters, cancellationToken);
|
||||
}
|
||||
|
|
|
@ -30,12 +30,7 @@ namespace MediaBrowser.Server.Implementations.Activity
|
|||
string[] queries = {
|
||||
|
||||
"create table if not exists ActivityLogEntries (Id GUID PRIMARY KEY, Name TEXT, Overview TEXT, ShortOverview TEXT, Type TEXT, ItemId TEXT, UserId TEXT, DateCreated DATETIME, LogSeverity TEXT)",
|
||||
"create index if not exists idx_ActivityLogEntries on ActivityLogEntries(Id)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory",
|
||||
|
||||
"pragma shrink_memory"
|
||||
"create index if not exists idx_ActivityLogEntries on ActivityLogEntries(Id)"
|
||||
};
|
||||
|
||||
connection.RunQueries(queries, Logger);
|
||||
|
|
|
@ -1309,7 +1309,15 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
AddUserToQuery(query, query.User);
|
||||
}
|
||||
|
||||
return ItemRepository.GetItems(query);
|
||||
if (query.EnableTotalRecordCount)
|
||||
{
|
||||
return ItemRepository.GetItems(query);
|
||||
}
|
||||
|
||||
return new QueryResult<BaseItem>
|
||||
{
|
||||
Items = ItemRepository.GetItemList(query).ToArray()
|
||||
};
|
||||
}
|
||||
|
||||
public List<Guid> GetItemIds(InternalItemsQuery query)
|
||||
|
|
|
@ -952,7 +952,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||
|
||||
if (query.Limit.HasValue)
|
||||
{
|
||||
internalQuery.Limit = Math.Max(query.Limit.Value * 5, 300);
|
||||
internalQuery.Limit = Math.Max(query.Limit.Value * 5, 200);
|
||||
}
|
||||
|
||||
if (query.HasAired.HasValue)
|
||||
|
|
|
@ -32,12 +32,7 @@ namespace MediaBrowser.Server.Implementations.Notifications
|
|||
|
||||
"create table if not exists Notifications (Id GUID NOT NULL, UserId GUID NOT NULL, Date DATETIME NOT NULL, Name TEXT NOT NULL, Description TEXT, Url TEXT, Level TEXT NOT NULL, IsRead BOOLEAN NOT NULL, Category TEXT NOT NULL, RelatedId TEXT, PRIMARY KEY (Id, UserId))",
|
||||
"create index if not exists idx_Notifications1 on Notifications(Id)",
|
||||
"create index if not exists idx_Notifications2 on Notifications(UserId)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory",
|
||||
|
||||
"pragma shrink_memory"
|
||||
"create index if not exists idx_Notifications2 on Notifications(UserId)"
|
||||
};
|
||||
|
||||
connection.RunQueries(queries, Logger);
|
||||
|
|
|
@ -20,9 +20,17 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
Logger = logManager.GetLogger(GetType().Name);
|
||||
}
|
||||
|
||||
protected Task<IDbConnection> CreateConnection(bool isReadOnly = false)
|
||||
protected virtual async Task<IDbConnection> CreateConnection(bool isReadOnly = false)
|
||||
{
|
||||
return DbConnector.Connect(DbFilePath, false, true);
|
||||
var connection = await DbConnector.Connect(DbFilePath, false, true).ConfigureAwait(false);
|
||||
|
||||
connection.RunQueries(new []
|
||||
{
|
||||
"pragma temp_store = memory"
|
||||
|
||||
}, Logger);
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
private bool _disposed;
|
||||
|
|
|
@ -53,12 +53,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
string[] queries = {
|
||||
|
||||
"create table if not exists userdisplaypreferences (id GUID, userId GUID, client text, data BLOB)",
|
||||
"create unique index if not exists userdisplaypreferencesindex on userdisplaypreferences (id, userId, client)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory",
|
||||
|
||||
"pragma shrink_memory"
|
||||
"create unique index if not exists userdisplaypreferencesindex on userdisplaypreferences (id, userId, client)"
|
||||
};
|
||||
|
||||
connection.RunQueries(queries, Logger);
|
||||
|
|
|
@ -26,8 +26,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
throw new ArgumentNullException("dbPath");
|
||||
}
|
||||
|
||||
logger.Info("Sqlite {0} opening {1}", SQLiteConnection.SQLiteVersion, dbPath);
|
||||
|
||||
var connectionstr = new SQLiteConnectionStringBuilder
|
||||
{
|
||||
PageSize = 4096,
|
||||
|
@ -39,7 +37,16 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
ReadOnly = isReadOnly
|
||||
};
|
||||
|
||||
var connection = new SQLiteConnection(connectionstr.ConnectionString);
|
||||
var connectionString = connectionstr.ConnectionString;
|
||||
|
||||
if (enablePooling)
|
||||
{
|
||||
connectionString += ";Max Pool Size=100";
|
||||
}
|
||||
|
||||
//logger.Info("Sqlite {0} opening {1}", SQLiteConnection.SQLiteVersion, connectionString);
|
||||
|
||||
var connection = new SQLiteConnection(connectionString);
|
||||
|
||||
await connection.OpenAsync().ConfigureAwait(false);
|
||||
|
||||
|
|
|
@ -44,12 +44,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
string[] queries = {
|
||||
|
||||
"create table if not exists FileOrganizerResults (ResultId GUID PRIMARY KEY, OriginalPath TEXT, TargetPath TEXT, FileLength INT, OrganizationDate datetime, Status TEXT, OrganizationType TEXT, StatusMessage TEXT, ExtractedName TEXT, ExtractedYear int null, ExtractedSeasonNumber int null, ExtractedEpisodeNumber int null, ExtractedEndingEpisodeNumber, DuplicatePaths TEXT int null)",
|
||||
"create index if not exists idx_FileOrganizerResults on FileOrganizerResults(ResultId)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory",
|
||||
|
||||
"pragma shrink_memory"
|
||||
"create index if not exists idx_FileOrganizerResults on FileOrganizerResults(ResultId)"
|
||||
};
|
||||
|
||||
_connection.RunQueries(queries, Logger);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -45,12 +45,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
"create table if not exists userdata (key nvarchar, userId GUID, rating float null, played bit, playCount int, isFavorite bit, playbackPositionTicks bigint, lastPlayedDate datetime null)",
|
||||
|
||||
"create index if not exists idx_userdata on userdata(key)",
|
||||
"create unique index if not exists userdataindex on userdata (key, userId)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory",
|
||||
|
||||
"pragma shrink_memory"
|
||||
"create unique index if not exists userdataindex on userdata (key, userId)"
|
||||
};
|
||||
|
||||
connection.RunQueries(queries, Logger);
|
||||
|
|
|
@ -52,9 +52,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
"create index if not exists idx_users on users(guid)",
|
||||
"create table if not exists schema_version (table_name primary key, version)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory",
|
||||
|
||||
"pragma shrink_memory"
|
||||
};
|
||||
|
||||
|
|
|
@ -32,12 +32,7 @@ namespace MediaBrowser.Server.Implementations.Security
|
|||
string[] queries = {
|
||||
|
||||
"create table if not exists AccessTokens (Id GUID PRIMARY KEY, AccessToken TEXT NOT NULL, DeviceId TEXT, AppName TEXT, AppVersion TEXT, DeviceName TEXT, UserId TEXT, IsActive BIT, DateCreated DATETIME NOT NULL, DateRevoked DATETIME)",
|
||||
"create index if not exists idx_AccessTokens on AccessTokens(Id)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory",
|
||||
|
||||
"pragma shrink_memory"
|
||||
"create index if not exists idx_AccessTokens on AccessTokens(Id)"
|
||||
};
|
||||
|
||||
connection.RunQueries(queries, Logger);
|
||||
|
|
|
@ -31,9 +31,6 @@ namespace MediaBrowser.Server.Implementations.Social
|
|||
"create table if not exists Shares (Id GUID, ItemId TEXT, UserId TEXT, ExpirationDate DateTime, PRIMARY KEY (Id))",
|
||||
"create index if not exists idx_Shares on Shares(Id)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory",
|
||||
|
||||
"pragma shrink_memory"
|
||||
};
|
||||
|
||||
|
|
|
@ -43,9 +43,6 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
"create index if not exists idx_SyncJobItems1 on SyncJobItems(Id)",
|
||||
"create index if not exists idx_SyncJobItems2 on SyncJobItems(TargetId)",
|
||||
|
||||
//pragmas
|
||||
"pragma temp_store = memory",
|
||||
|
||||
"pragma shrink_memory"
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user