diff --git a/PluralKit.Core/Database/Database.cs b/PluralKit.Core/Database/Database.cs index e43c9966..0bc88ad1 100644 --- a/PluralKit.Core/Database/Database.cs +++ b/PluralKit.Core/Database/Database.cs @@ -25,6 +25,7 @@ namespace PluralKit.Core private readonly ILogger _logger; private readonly IMetrics _metrics; private readonly DbConnectionCountHolder _countHolder; + private readonly string _connectionString; public Database(CoreConfig config, DbConnectionCountHolder countHolder, ILogger logger, IMetrics metrics) @@ -33,6 +34,11 @@ namespace PluralKit.Core _countHolder = countHolder; _metrics = metrics; _logger = logger; + + _connectionString = new NpgsqlConnectionStringBuilder(_config.Database) + { + Pooling = true, MaxPoolSize = 500, Enlist = false, NoResetOnClose = true + }.ConnectionString; } public static void InitStatic() @@ -76,7 +82,7 @@ namespace PluralKit.Core // Create a connection and open it // We wrap it in PKConnection for tracing purposes - var conn = new PKConnection(new NpgsqlConnection(_config.Database), _countHolder, _logger, _metrics); + var conn = new PKConnection(new NpgsqlConnection(_connectionString), _countHolder, _logger, _metrics); await conn.OpenAsync(); return conn; }