0

Is there any way that I can perform my benchmarks for multiple queries in neo4j?

Assuming that I have loaded my graph, I want to initiate 10000 distinct shortest path queries in the database, without loading the data to a client. Is there a way that I can do this in a batch and get the execution times?

Chris
  • 47
  • 7

2 Answers2

3

Try using the profile keyword inside of the neo4j-shell. This will give you some basic facts about how quickly, and how a query executes.

Here's a simple example:

neo4j-sh (?)$ CREATE (a {label:"foo"})-[:bar]->(b {label: "bar"})-[:bar]->(c {label: "baz"});
+-------------------+
| No data returned. |
+-------------------+
Nodes created: 3
Relationships created: 2
Properties set: 3
1180 ms
neo4j-sh (?)$ profile match (a {label: "foo"}), (c {label: "baz"}), p=shortestPath(a-[*]-c) return p;
+--------------------------------------------------------------------------------------+
| p                                                                                    |
+--------------------------------------------------------------------------------------+
| [Node[0]{label:"foo"},:bar[0]{},Node[1]{label:"bar"},:bar[1]{},Node[2]{label:"baz"}] |
+--------------------------------------------------------------------------------------+
1 row

ColumnFilter
  |
  +ShortestPath
    |
    +Filter(0)
      |
      +AllNodes(0)
        |
        +Filter(1)
          |
          +AllNodes(1)

+--------------+------+--------+-------------+-----------------------------------------+
|     Operator | Rows | DbHits | Identifiers |                                   Other |
+--------------+------+--------+-------------+-----------------------------------------+
| ColumnFilter |    1 |      0 |             |                          keep columns p |
| ShortestPath |    1 |      0 |           p |                                         |
|    Filter(0) |    1 |      6 |             | Property(c,label(0)) == {  AUTOSTRING1} |
|  AllNodes(0) |    3 |      4 |        c, c |                                         |
|    Filter(1) |    1 |      6 |             | Property(a,label(0)) == {  AUTOSTRING0} |
|  AllNodes(1) |    3 |      4 |        a, a |                                         |
+--------------+------+--------+-------------+-----------------------------------------+

This other answer indicates that you're usually looking for lower DbHits values to be indicative of better performance, since those are expensive.

Community
  • 1
  • 1
FrobberOfBits
  • 17,634
  • 4
  • 52
  • 86
  • I would also up vote your answer but I do not have enough reputation. Is there any way to run the profile in a batch of 1000 queries with one cypher command? – Chris Oct 20 '14 at 09:41
  • Well, you can't run 1,000 queries with any one command, they're 1,000 queries. :) But you can put "profile" in front of each query, and it will execute and give you info on the query. So do it once per query. If you have all 1,000 queries in a file, you can use shell tricks to automatically prepend the "profile " before each line. – FrobberOfBits Oct 20 '14 at 12:26
3

The WebAdmin tools (usually at http://localhost:7474/webadmin/ for a local neo4j installation), has Data browser and Console tabs that allow you to enter your query, see the results, and also see the actual time it took to perform the query.

Interestingly, from my limited testing of the Data browser and Console tabs, the latter seems to report faster query times for the same queries. So, the Console probably has less overhead, possibly making its timing results a bit more accurate.

cybersam
  • 63,203
  • 6
  • 53
  • 76