Metabase DB cleanup?

Hey, the reason the application DB is so large is probably because the log of query executions has grown to be pretty big. We’re discussing how we can rotate this out in the future but in the meantime you can delete what’s currently the query_execution log if you don’t need it for auditing purposes. (I’m guessing you don’t if it’s a single-user instance you’re running locally)

Get an H2 shell like this:

# H2 automatically adds .h2.db or .mv.db suffix so do not specify it
java -cp metabase.jar org.h2.tools.Shell -url jdbc:h2:./metabase.db -user '' -password '' -driver org.h2.Driver

Or when running with Leiningen, we have an alias for that command:

lein h2

Then at the SQL prompt:

sql> TRUNCATE TABLE query_execution;

That will delete all the rows in the query execution log which should bring the database back to a reasonable size.

That should be all you need to do. With Postgres or MySQL you can connect to the database using psql or mysql and run the same command

2 Likes