NOTE: The query in this article needs to read the entire graph, therefore it can be very slow especially on larger datasets. It is not recommended to run this query within your regular working hours as performance may be affected.
The purpose of this article is to assist you to make an informed decision on whether performing a compaction of your database store can save you disk space. The way we can do so is by using the query that follows, which will you show you the estimated usage of the nodes and relationships on disk. This excludes deleted nodes that have yet to be cleaned up by a compaction:
WITH SUM(SIZE(KEYS(n))) AS countOfNodeProps,
SUM(SIZE(KEYS(n))) AS sizeOfNodeProps,
COUNT(n) AS countOfNodes,
COUNT(n) AS sizeOfNodes
SUM(SIZE(KEYS(r))) AS countOfRelProps,
SUM(SIZE(KEYS(r))) AS sizeOfRelProps,
COUNT(r) AS countOfRels,
COUNT(r) AS sizeOfRels
(countOfNodeProps + countOfRelProps) as countOfProps,
(sizeOfNodeProps + sizeOfRelProps) as sizeOfAllProps,
((sizeOfNodeProps*40) + (sizeOfRelProps*40) + (sizeOfNodes*34) + (sizeOfRels*41))/1024/1024/1024 as sizeOfStoreGB
The result of the query should be similar to the example shown below. For the purposes of this document, for the example we have used a database where nearly all of the nodes have been deleted but the space has not yet been freed by a compaction:
you can compare the sizeOfStoreGB column from the query results, to the Storage Used (%) metric for the database on the console, as seen below:
A large discrepancy between the two indicates that a compaction can save you the difference in space, although the freed space may vary as your dataset is likely changing/growing.
For more information on performing a compaction please follow the following article: https://neotechnology.zendesk.com/knowledge/articles/4408091782675/en-us?brand_id=360002349334
Please sign in to leave a comment.