mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 12:44:07 -08:00
⚡ 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:
commit
2086ef7cf4
|
@ -12,6 +12,7 @@ import {
|
||||||
ActiveWorkflowRunner,
|
ActiveWorkflowRunner,
|
||||||
CredentialsOverwrites,
|
CredentialsOverwrites,
|
||||||
CredentialTypes,
|
CredentialTypes,
|
||||||
|
DatabaseType,
|
||||||
Db,
|
Db,
|
||||||
ExternalHooks,
|
ExternalHooks,
|
||||||
GenericHelpers,
|
GenericHelpers,
|
||||||
|
@ -156,6 +157,15 @@ export class Start extends Command {
|
||||||
// Wait till the database is ready
|
// Wait till the database is ready
|
||||||
await startDbInitPromise;
|
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) {
|
if (flags.tunnel === true) {
|
||||||
this.log('\nWaiting for tunnel ...');
|
this.log('\nWaiting for tunnel ...');
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,14 @@ const config = convict({
|
||||||
env: 'DB_MYSQLDB_USER',
|
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: {
|
credentials: {
|
||||||
|
|
Loading…
Reference in a new issue