我找到了有关如何计算neo4j数据库大小的以下信息:https://neo4j.com/developer/guide-sizing-and-hardware-calculator/#_disk_storage
示例磁盘空间计算是:
10,000个节点x 14B = 140kB 1,000,000 Rels x 33B = 31.5MB 2,010,000 道具x 41B = 78.6MB
总计为110.2MB
是否有可以简单地为我提取此信息的查询?
对于节点计数,查询很简单:
match (n) return count(n);
对于rel计数,查询将如下:
match (n)-[r]-() return count(r);
如何计算所有节点和关系的所有属性的计数?
答案 0 :(得分:1)
回答您的主要问题,使用keys
函数获取属性名称列表并总结其长度:
MATCH (n)
WITH SUM(SIZE(KEYS(n))) AS countOfNodeProps,
COUNT(n) AS countOfNodes
MATCH ()-[r]->()
WITH countOfNodeProps,
countOfNodes,
SUM(SIZE(KEYS(r))) AS countOfRelProps,
COUNT(r) AS countOfRels
RETURN countOfNodeProps,
countOfRelProps,
(countOfNodeProps + countOfRelProps) as countOfProps,
countOfNodes,
countOfRels
但使用apoc.monitor.store
功能获取有关存储的确切信息更容易:
CALL apoc.monitor.store() YIELD
logSize,
stringStoreSize,
arrayStoreSize,
relStoreSize,
propStoreSize,
totalStoreSize,
nodeStoreSize
RETURN *