Created
July 18, 2022 18:50
-
-
Save favila/587543c4d338106f8434987215c0acc2 to your computer and use it in GitHub Desktop.
Vaccum or compact unused space from an h2 database (especially for datomic)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Uses the h2 jar in a datomic distribution to give raw SQL access | |
# to the h2 database datomic "dev" storage uses. | |
# The 'SHUTDOWN COMPACT' command in particular performs all | |
# vaccum-like compaction of the h2 database file to remove | |
# unused blocks from deleted (garbage-collected) segments. | |
DATOMIC_HOME=${DATOMIC:-$HOME/lib/datomic/current} | |
DATOMIC_ADMIN_PASSWORD=${1:?Storage admin password must be provided} | |
DATOMIC_DATA_DIR=${2:-/usr/local/var/data/datomic/dev-internal} | |
echo $DATOMIC_HOME/lib/h2*.jar | |
exec java -server -XX:+UseParallelGC -cp ${DATOMIC_HOME}/lib/h2*.jar \ | |
org.h2.tools.Shell \ | |
-url "jdbc:h2:${DATOMIC_DATA_DIR}/db/datomic;IFEXISTS=TRUE;" \ | |
-user '' -password "$DATOMIC_ADMIN_PASSWORD" \ | |
-sql 'SHUTDOWN COMPACT;' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment