Possible to Reduce Database Size by Deleting From "insights_raw" Table

Describe the problem/error/question

Hello,
Is it possible to delete data from the “insights_raw” table to reduce the database size? Insights are already turned off, so there won’t be any need for it at the moment, but the insights table accounts for 92% of the total database size.
Thank you.

Information on your n8n setup

  • n8n version: 2.9.3
  • Database: SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): Default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Debian 12

Here’s the screenshot of table sizes.

2 Likes

Hi @MarleTangible

before you proceed I’d strongly recommend Take a full database backup first
since you already turned insights off, n8n isn’t using that data for anything anyway. it just powers the built-in usage dashboards. dropping those rows won’t break your workflows.

there’s a catch with sqlite though. if you just run DELETE FROM insights_raw;, the actual database file size on your disk won’t change. sqlite just marks the space as empty inside the file for later.

to actually shrink the database and get your storage back, you have to run VACUUM; right after your delete command.

just make sure you stop your n8n docker container first before opening the sqlite file and running those commands stops database locking issues.

Hope this will help you!

2 Likes

Hello, thank you for your reply.

We also have the insights dashboard off as well, so we can just remove the data then. Regarding the need for size reduction, there’s an environment variable we found which shrinks the database on restarts, so that’s covered as well.

DB_SQLITE_VACUUM_ON_STARTUP=true

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.