【问题标题】:Cypher query execution time with Neo4j java driver使用 Neo4j java 驱动程序的 Cypher 查询执行时间
【发布时间】:2016-12-30 19:06:31
【问题描述】:

我正在尝试使用 java 驱动程序找出我的 Cypher 查询的执行时间。

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" );

但我在StatementResultResultSummary 的任何地方都找不到它,这是由StatementResult.consume(query) 返回的。

我可以在ResultSummary 中访问来自ProfiledPlan 的数据库命中,但没有关于时间的信息。

有什么方法可以使用 neo4j java 驱动程序访问 Cypher 查询执行时间?

【问题讨论】:

  • 嗨,你能简单地告诉我a之前创建人CREATE (a:Person ...代表什么。我一直看到它。是否类似于 JPQL 中的 statefield

标签: java neo4j cypher neo4j-java-api


【解决方案1】:

从 Neo4j Java 驱动程序版本 1.1.0 开始有:

/**
 * 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 );

它为您提供两种时间:

  1. 距离第一个字节的时间
  2. 完整的执行时间,包括使用来自服务器的数据

方法本地化在org.neo4j.driver.v1.summary.ResultSummary 接口上。

【讨论】:

  • 谢谢@arezoo,你是对的。我错过了它,因为它仅在最新的 neo4j-java-driver 1.1.0 中可用,而我使用的是 1.0.5
  • 您好,您能告诉我 ResultSummary 是如何集成到您的代码中的吗?请
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多