rlay-project / rlay-client

Reference implementation of the Rlay client
https://rlay-project.github.io/rlay-client/
Apache License 2.0
4 stars 0 forks source link

feat/neo4j: add double `RlayEntity` index when storing entity #34

Closed MichaelHirn closed 5 years ago

MichaelHirn commented 5 years ago

Some documentation on double index

Performance

1st the plain one (edited) MATCH (n { cid: "0x019c80031b20054fe6f41013f1b17093941e4efca591bf5e1594b5af54f5361ba799181922d2"}) MERGE (m { cid: "0x019480031b2035722634214d0674be81a19f86199cd7358bc697f13ed93252a728b68e4dde8d" }) MERGE (n)-[r:property]->(m) execution time: Completed after 968 ms. :snail: (edited) 2nd the index one (current standard) MATCH (n:RlayEntity { cid: "0x019c80031b20054fe6f41013f1b17093941e4efca591bf5e1594b5af54f5361ba799181922d2"}) MERGE (m { cid: "0x019480031b2035722634214d0674be81a19f86199cd7358bc697f13ed93252a728b68e4dde8d" }) MERGE (n)-[r:property]->(m) execution time: Completed after 317 ms. :fire: (edited) 3rd the double index one MATCH (n:RlayEntity { cid: "0x019c80031b20054fe6f41013f1b17093941e4efca591bf5e1594b5af54f5361ba799181922d2"}) MERGE (m:RlayEntity { cid: "0x019480031b2035722634214d0674be81a19f86199cd7358bc697f13ed93252a728b68e4dde8d" }) MERGE (n)-[r:property]->(m) execution time: Completed after 1 ms. :fire::fire::fire:

Unexpected behavior

I run the raw queries against an empty db and here’s what I noticed 1 index only 1st run -> Created 1 node, set 1 property, created 1 relationship 2nd run -> (no changes) Double index 1st run -> Added 1 label, created 1 node, set 1 property, created 1 relationship 2nd run -> (no changes) (edited) So I guess it really just adds the label? Will also query them now and see if the graphs look any different

Michael Hirn [10:17 AM] Ok, the problem seems to be, that if you run the double index query on Data/Object Props that already exist (who normally don’t have a RlayEntity label) it creates a new node with the same cid And then also the new relationship is with the second node and not the first one as it should be

Maximilian Goisser [10:18 AM] What if the node already exists with :RlayEntity and has some other properties besides cid?

Michael Hirn [10:19 AM] good question. I also have to test what happens if that Data/Object Prop has a RlayEntity already So, if the Data/Object Prop has a RlayEntity label already, it does not create a new node Data/Object Prop has a RlayEntity label already and also has additional properties (e.g. a target), it also does not create a new node So, I guess if I make sure that all nodes have a RlayEntity label in the db, it should be fine?