Run vacuum on sqlite on startup according to settings (#1290)

* Run vacuum on sqlite periodically

* Changed vacuum operation to run on startup only. Also it is now off by default.

* Removing console.log message
This commit is contained in:
Jan
2021-01-07 13:18:24 +01:00
committed by GitHub
2 changed files with 18 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ import {
ActiveWorkflowRunner,
CredentialsOverwrites,
CredentialTypes,
DatabaseType,
Db,
ExternalHooks,
GenericHelpers,
@@ -156,6 +157,15 @@ export class Start extends Command {
// Wait till the database is ready
await startDbInitPromise;
const dbType = await GenericHelpers.getConfigValue('database.type') as DatabaseType;
if (dbType === 'sqlite') {
const shouldRunVacuum = config.get('database.sqlite.executeVacuumOnStartup') as number;
if (shouldRunVacuum) {
Db.collections.Execution!.query("VACUUM;");
}
}
if (flags.tunnel === true) {
this.log('\nWaiting for tunnel ...');

View File

@@ -124,6 +124,14 @@ const config = convict({
env: 'DB_MYSQLDB_USER',
},
},
sqlite: {
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 start-up time.',
format: Boolean,
default: false,
env: 'DB_SQLITE_VACUUM_ON_STARTUP',
},
},
},
credentials: {