cancel
Showing results for 
Search instead for 
Did you mean: 

Defrag the database

mvirnig2
Node

We are using Neo4j 4.0

We have found that we can significantly shrink (defragment) the database by performing neo4j-admin copy operation. We would like to be able to achieve this outcome without having stop/start the database and rewrite the database. Is there anyway to have Neo4j defrag dynamically?

1 REPLY 1

No.

The graph ids of nodes and relationships are changed during a copy operation, and since these work as pointers between nodes and relationships in the store (we use these for most database operations, including traversal), there is no way to perform this at runtime.

Keep in mind that Neo4j will reuse portions of the deleted store files as new data is created, and we have greatly improved id reuse features in 4.x. We would advise relying on the id reuse features in 4.x and save neo4j-admin copy for infrequent use, or when dealing with inconsistencies in the graph.