From 04a8912a945441833323f61eaec1ea641184f260 Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Mon, 4 Jan 2021 09:30:02 +0100 Subject: [PATCH] Changed vacuum operation to run on startup only. Also it is now off by default. --- packages/cli/commands/start.ts | 8 +++----- packages/cli/config/index.ts | 10 +++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/cli/commands/start.ts b/packages/cli/commands/start.ts index 52c5cd33dd..409c2b763c 100644 --- a/packages/cli/commands/start.ts +++ b/packages/cli/commands/start.ts @@ -160,12 +160,10 @@ export class Start extends Command { const dbType = await GenericHelpers.getConfigValue('database.type') as DatabaseType; if (dbType === 'sqlite') { - const vacuumInterval = config.get('database.sqlite.vacuumInterval') as number; - if (vacuumInterval >= 0) { + const shouldRunVacuum = config.get('database.sqlite.executeVacuumOnStartup') as number; + if (shouldRunVacuum) { + console.log('ran vacuum'); Db.collections.Execution!.query("VACUUM;"); - if (vacuumInterval > 0) { - setInterval(() => Db.collections.Execution!.query("VACUUM;"), vacuumInterval * 1000); - } } } diff --git a/packages/cli/config/index.ts b/packages/cli/config/index.ts index f8a348274a..05ef88771e 100644 --- a/packages/cli/config/index.ts +++ b/packages/cli/config/index.ts @@ -125,11 +125,11 @@ const config = convict({ }, }, sqlite: { - vacuumInterval: { - doc: 'SQLite Vacuum operation interval', - format: Number, - default: 86400, // Given in seconds; -1 disables. 0 executes only at startup. - env: 'DB_SQLITE_VACUUM_INTERVAL', + executeVacuumOnStartup: { + doc: 'Runs VACUUM operation on startup to rebuild the database. Reduces filesize and optimizes indexes. WARNING: This is a long running blocking operation. Will increase boot time.', + format: Boolean, + default: false, + env: 'DB_SQLITE_VACUUM_ON_STARTUP', }, }, },