使用 java 配置文件 neo4j 数据库命中



我正在尝试使用以下代码分析 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;
}

总的来说,我这样称呼它

Result result = neo4jGraph.execute(query);
int hits = calculateHits(result.getExecutionPlanDescription().getChildren()); 

但是,该方法始终返回 0 次命中。我记录了queryExecuter计划的名称,并找到了EagerAggregation,Filter。展开(全部(、过滤器和 NodeByLabelScan 计划。但似乎并非所有计划都存在探查器统计信息,因为它永远不会访问条件并增加命中率。

代码中是否有任何问题,或者我需要先进行某些配置来分析数据库命中?感谢您的帮助。谢谢!

我终于想通了问题所在!我必须在查询中使用配置文件来填充统计信息并获得数据库命中。所以查询应该是

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)}

最新更新