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 is as follows:
+-----------------------+------+---------+----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+ | 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 to separate MATCH + WHERE from CREATE in this case to remove EAGER?
Is my only way to project CSV into a new one with the PRECEDES relation defined in it before stuffing the pre-built relations into a graph? Or is there a way to build a consistent relationship with the best MATCH.