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.