简体   繁体   English

使用 java 分析 neo4j 数据库命中

[英]Profile neo4j database hits using java

I am trying to profile neo4j database hits using the following code我正在尝试使用以下代码分析 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;
}

in main I call it this way主要是我这样称呼它

Result result = neo4jGraph.execute(query);

int hits = calculateHits(result.getExecutionPlanDescription().getChildren()); 

However, the method always returns 0 hits.但是,该方法始终返回 0 个命中。 I logged the names of queryExecuter plans and found EagerAggregation, Filter.我记录了 queryExecuter 计划的名称并找到了 EagerAggregation、Filter。 Expand(All), Filter, and NodeByLabelScan plans. Expand(All)、Filter 和 NodeByLabelScan 计划。 But seems that profilerStatistics do not exist for all the plans as it never accesses the condition and increases the hits.但似乎所有计划都不存在 profilerStatistics,因为它从不访问条件并增加命中率。

Is there any problem in the code or I need to make certain configuration first to profile the DB hits?代码中是否有任何问题,或者我需要先进行某些配置来分析数据库命中? ... appreciate your help. ... 感谢你的帮助。 Thanks!谢谢!

I figured out the problem finally!我终于找到了问题所在! I have to use profile in the query to fill the statistics and get the DB hits.我必须在查询中使用配置文件来填充统计信息并获取数据库命中。 so the query should be所以查询应该是

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM