我正在尝试使用以下代码分析neo4j数据库的命中率
public int calculateHits(List<ExecutionPlanDescription> list) {
int hits = 0;
int head = 0;
if (list.isEmpty())
return 0;
if (list.get(head).hasProfilerStatistics()) {
hits += list.get(head).getProfilerStatistics().getDbHits();
System.out.println(hits);
}
hits += calculateHits(list.get(head).getChildren()); // recurse over the children of the head
list.remove(head); // remove the head to recurse on the remaining of the list
hits += calculateHits(list);
return hits;
}在main中,我这样称呼它
Result result = neo4jGraph.execute(query);
int hits = calculateHits(result.getExecutionPlanDescription().getChildren()); 但是,该方法始终返回0次命中。我记录了queryExecuter计划的名称并找到了EagerAggregation和Filter。展开(全部)、筛选和NodeByLabelScan计划。但似乎并不是所有的计划都存在profilerStatistics,因为它从不访问条件并增加命中率。
是否在代码中有任何问题,或者我需要首先进行某些配置,以分析数据库命中?感谢你的帮助。谢谢!
发布于 2017-08-09 19:21:18
我终于找到问题所在了!我必须在查询中使用profile来填充统计数据并获得数据库命中率。因此,查询应该是
PROFILE Match (e:Event)-[r:has_metadata]-> (s:EventMetadata) where s.type STARTS WITH 'ELec' AND s.eventLocation IN ["GW", "GW32", "FW", "FW29" , "SW", "SW00"] AND e.date="1/11/2016" return SUM( e.reading)}https://stackoverflow.com/questions/42024195
复制相似问题