Why is my database so big?

Hey @aston_he,

Have you enabled pruning? I suggest you set the environment variable EXECUTIONS_DATA_PRUNE to true. You can also set a max age using the environment variable EXECUTIONS_DATA_MAX_AGE .

You find more information here: Environment Variables | Docs

I run n8n in the docker,I use the default setting.

You should then add these to your configuration. If you’ve setup environment variables in an .env file, you can add these in that same file

How can I set up this?Please give an advice.

@aston_he in your Docker Compose file (if you are using it) you will have the environment options. In there you can add the extra options, As an example in the instances I have running I use…

      - EXECUTIONS_DATA_SAVE_ON_ERROR=all
      - EXECUTIONS_DATA_SAVE_ON_SUCCESS=none
      - EXECUTIONS_DATA_SAVE_ON_PROGRESS=true
      - EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=false
      - EXECUTIONS_DATA_PRUNE=true
      - EXECUTIONS_DATA_MAX_AGE=168

This makes my full docker-compose.yml look like this:

version: "3"
services:
  n8n:
    container_name: n8n
    image: n8nio/n8n
    restart: always
    ports:
      - "127.0.0.1:5678:5678"
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER
      - N8N_BASIC_AUTH_PASSWORD
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=http
      - NODE_ENV=production
      - VUE_APP_URL_BASE_API=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - WEBHOOK_TUNNEL_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
      - EXECUTIONS_PROCESS=main
      - EXECUTIONS_DATA_SAVE_ON_ERROR=all
      - EXECUTIONS_DATA_SAVE_ON_SUCCESS=none
      - EXECUTIONS_DATA_SAVE_ON_PROGRESS=true
      - EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=false
      - EXECUTIONS_DATA_PRUNE=true
      - EXECUTIONS_DATA_MAX_AGE=168
    volumes:
      - ${DATA_FOLDER}/.n8n:/home/node/.n8n

My .env file looks like this:

DATA_FOLDER=/home/username/n8n/data

DOMAIN_NAME=mydomain.tld
SUBDOMAIN=n8n-service

N8N_BASIC_AUTH_USER=ADMIN_USERNAME_HERE
N8N_BASIC_AUTH_PASSWORD=ADMIN_PASSWORD_HERE

# Timezone
GENERIC_TIMEZONE=Europe/London
2 Likes

You are the best.

2 Likes

It is worth having the other bits as you probably won’t need all the logging… or at least I have found that we don’t need it anyway.

And how can I reduce the exist database now?It sees so big.

You need to set the EXECUTIONS_DATA_PRUNE option.

I have done.As you said.

Perfect, I think you might also need DB_SQLITE_VACUUM_ON_STARTUP to clean up what is already there.

DB_SQLITE_VACUUM_ON_STARTUP = true
1 Like

Good!
The database is reduced now!

2 Likes

Hello, I am facing this error.

environment variable name 'DB_SQLITE_VACUUM_ON_STARTUP ' may not contain whitespace

below is my docker-compose.yml

      - EXECUTIONS_DATA_SAVE_ON_SUCCESS=none
      - EXECUTIONS_DATA_SAVE_ON_ERROR=all
      - EXECUTIONS_DATA_SAVE_ON_PROGRESS=true
      - EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=false
      - EXECUTIONS_DATA_MAX_AGE=168
      - DB_SQLITE_VACUUM_ON_STARTUP = true
    volumes:
      - /home/ubuntu/n8n/n8n_data:/home/node/.n8n

may i know what is wrong?

now i know what is wrong. there should not have any space before and afte “=” sign. in the environment.

1 Like

Hello,
I’ve installed n8n with YunoHost and now my database is more than 30gb. Can I execute these commands now or only during the installation of n8n?
Thank you

Hey @theRAGEhero,

Welcome to the community :birthday:

You can add the environment options to clear down the database logs and vacuum if using SQLite at any time. It may take a while for the service to start back up as it will have a lot to do but give it 5 minutes or so and see how it is looking.