Closing the H2 database; Compact vs Defrag?

In my application, I connect to an H2 database, and I recently studied how this database ends up.

In my connection string, I set DEFRAG_ALWAYS=true , which according to H2 doc

Each time the database is closed, it is completely defragmented (SHUTDOWN DEFRAG).

Now I assume that when the JVM shuts down, the completion hook will stop the database and defragment it (as if SHUTDOWN DEFRAG ).

But if I had to do SHUTDOWN COMPACT before exiting the application, while DEFRAG_ALWAYS=true was applied in the connection string, what shutdown process would be used?

+6
source share
1 answer

If you perform a shutdown manually, this takes precedence over the setting ( defrag_always=true ). Therefore, if you perform shutdown compact , then this is what is done, and defrag not executed. If you execute shutdown defrag , then this will be done no matter what parameter. If you just close the database normally, then the defrag_always setting is defrag_always .

+6
source

Source: https://habr.com/ru/post/976386/


All Articles