Cypher query execution time with Neo4j java driver

瘦欲@ 提交于 2019-12-07 18:55:02

问题


I am trying to find out execution time of my Cypher query with java driver.

Session session = driver.session();
session.run( "CREATE (a:Person {name:'Arthur', title:'King'})" );
StatementResult result = session.run( "Profile MATCH (a:Person) WHERE a.name = 'Arthur' RETURN a.name AS name, a.title AS title" );

But I could not find it anywhere in the StatementResult or in the ResultSummary, which is returned by StatementResult.consume(query).

I could access db hits from ProfiledPlan in ResultSummary but there is no information about time.

Is there any way I can access Cypher query execution time using neo4j java driver?


回答1:


Since Neo4j Java driver version 1.1.0 there is:

/**
 * The time it took the server to make the result available for consumption.
 *
 * @param unit The unit of the duration.
 * @return The time it took for the server to have the result available in the provided time unit.
 */
long resultAvailableAfter( TimeUnit unit );

/**
 * The time it took the server to consume the result.
 *
 * @param unit The unit of the duration.
 * @return The time it took for the server to consume the result in the provided time unit.
 */
long resultConsumedAfter( TimeUnit unit );

It provides you with both times:

  1. Time till first byte
  2. Full execution time including consuming data from server

Methods are localted on org.neo4j.driver.v1.summary.ResultSummary interface.



来源:https://stackoverflow.com/questions/41401424/cypher-query-execution-time-with-neo4j-java-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!