From 0b53c3189b15790abf67a13a66f6ff2d689b697f Mon Sep 17 00:00:00 2001 From: Jugurtha Bouhadoun Date: Tue, 9 Jul 2024 09:27:00 +0200 Subject: [PATCH 1/3] imporve database performence --- lib/util/sequelize.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/util/sequelize.js b/lib/util/sequelize.js index b65eb6e8..f3946e92 100644 --- a/lib/util/sequelize.js +++ b/lib/util/sequelize.js @@ -4,13 +4,20 @@ const {POSTGRES_BAN_USER, POSTGRES_BAN_PASSWORD, POSTGRES_DB, POSTGRES_URL} = pr const POSTGRES_PORT = process.env.POSTGRES_PORT || 5432 // Create a new Sequelize instance +/* eslint-disable unicorn/numeric-separators-style */ export const sequelize = new Sequelize(POSTGRES_DB, POSTGRES_BAN_USER, POSTGRES_BAN_PASSWORD, { host: POSTGRES_URL, port: POSTGRES_PORT, dialect: 'postgres', - logging: false + logging: false, + pool: { + max: 20, + min: 0, + acquire: 60000, + idle: 5000 + } }) - +/* eslint-enable unicorn/numeric-separators-style */ export const District = sequelize.define('District', { id: { type: DataTypes.UUID, From d2a1508f253ffa2add4312caa8c530f16c71c3bd Mon Sep 17 00:00:00 2001 From: Jugurtha Bouhadoun Date: Tue, 9 Jul 2024 14:55:56 +0200 Subject: [PATCH 2/3] increase maximum connexion number --- lib/util/sequelize.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/sequelize.js b/lib/util/sequelize.js index f3946e92..19331ae4 100644 --- a/lib/util/sequelize.js +++ b/lib/util/sequelize.js @@ -11,7 +11,7 @@ export const sequelize = new Sequelize(POSTGRES_DB, POSTGRES_BAN_USER, POSTGRES_ dialect: 'postgres', logging: false, pool: { - max: 20, + max: 80, min: 0, acquire: 60000, idle: 5000 From 892fc6ea88f34d8bc29d8688c5cb75ea8a1132d6 Mon Sep 17 00:00:00 2001 From: Jugurtha Bouhadoun Date: Tue, 16 Jul 2024 10:04:33 +0200 Subject: [PATCH 3/3] remove unused transition --- lib/api/consumers/export-to-exploitation-db-consumer.js | 5 ----- lib/util/sequelize.js | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/api/consumers/export-to-exploitation-db-consumer.js b/lib/api/consumers/export-to-exploitation-db-consumer.js index 9559fc7f..c7e32274 100644 --- a/lib/api/consumers/export-to-exploitation-db-consumer.js +++ b/lib/api/consumers/export-to-exploitation-db-consumer.js @@ -84,11 +84,6 @@ export default async function exportToExploitationDB({data}) { }) try { - // Then start your transaction - const transaction = await sequelize.transaction({ - isolationLevel: Transaction.ISOLATION_LEVELS.REPEATABLE_READ - }) - // Find the district const district = await District.findOne({ where: {id: districtID}, transaction, diff --git a/lib/util/sequelize.js b/lib/util/sequelize.js index 19331ae4..f3946e92 100644 --- a/lib/util/sequelize.js +++ b/lib/util/sequelize.js @@ -11,7 +11,7 @@ export const sequelize = new Sequelize(POSTGRES_DB, POSTGRES_BAN_USER, POSTGRES_ dialect: 'postgres', logging: false, pool: { - max: 80, + max: 20, min: 0, acquire: 60000, idle: 5000