5

neo4j version 2.3.1

Indexes exist on Stoptime.stop_sequence and Stoptime.key. Stoptime.stop_sequence is numeric.

Graph:

(Stoptime)-[:PART_OF]->(Trip)

Statement:

//USING PERIODIC COMMIT 1000
PROFILE
load csv with headers from "file:///path/to/csv" as csv with csv limit 0
match (s1:Stoptime{key:(csv.trip_id + csv.stop_id)})-[:PART_OF]->(trip:Trip), (s2:Stoptime)-[:PART_OF]->(trip)
where s2.stop_sequence = s1.stop_sequence + 1
create (s1)-[:PRECEDES]->(s2);

The resulting profile looks like this:

+-----------------------+------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| Operator              | Rows | DB Hits | Identifiers                                        | Other                                                                                                             |
+-----------------------+------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| +EmptyResult          |    0 |       0 |                                                    |                                                                                                                   |
| |                     +------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| +UpdateGraph          |    0 |       0 | anon[188], anon[227], anon[311], csv, s1, s2, trip | CreateRelationship                                                                                                |
| |                     +------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| +Eager                |    0 |       0 | anon[188], anon[227], csv, s1, s2, trip            |                                                                                                                   |
| |                     +------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| +Filter               |    0 |       0 | anon[188], anon[227], csv, s1, s2, trip            | Ands(trip:Trip, s2:Stoptime, s2.stop_sequence == Add(s1.stop_sequence,{  AUTOINT0}), NOT(anon[188] == anon[227])) |
| |                     +------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| +SimplePatternMatcher |    0 |       0 | anon[188], anon[227], csv, s1, s2, trip            |                                                                                                                   |
| |                     +------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| +SchemaIndex          |    0 |       0 | csv, s1                                            | Add(csv.trip_id,csv.stop_id); :Stoptime(key)                                                                      |
| |                     +------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| +Slice                |    0 |       0 | csv                                                | Literal(0)                                                                                                        |
| |                     +------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+
| +LoadCSV              |    1 |       0 | csv                                                |                                                                                                                   |
+-----------------------+------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+

How does one separate the MATCH + WHERE from the CREATE in this case to remove the EAGER?

Is my only resort to preprocess the CSV, into a new one with the PRECEDES relationship defined in it before stuffing the pre-built relationships into the graph? Or is there some way to build the consecutive relationship with a better MATCH.

changingrainbows
  • 2,551
  • 1
  • 28
  • 35
  • For anyone with a similar issue, this [blog post](http://www.markhneedham.com/blog/2014/10/23/neo4j-cypher-avoiding-the-eager/) covers this fairly well. – Tezra Sep 19 '17 at 17:23

1 Answers1

0

Cypher 3.x no longer has this problem. (If you run in Cypher 2.3 compatibility mode though, it won't go away)

So anyone who is having this problem, I would recommend upgrading to the latest version of Neo4j.

Tezra
  • 8,463
  • 3
  • 31
  • 68