pdpotter commented on issue #45:
URL: https://github.com/apache/incubator-age/issues/45#issuecomment-908222122


   When the edges are inserted in the specific edge table, they are 
automatically added to the `_ag_label_edge` table, reducing the workaround to 
the following and making the relation creation even faster:
   
   First, the underlying ids of the vertices are retrieved:
   ```
   SELECT * FROM cyper('graph_name',$$
   MATCH (n:LabelA)
   return id(n), n.id
   $$) as (id agtype, prop agtype);
   ```
   A single edge is then created using the cypher function to make sure the 
underlying tables are created correctly (the id values are made up)
   ```
   SELECT * FROM cypher('graph_name', $$
   MATCH (d:LabelA), (r:LabelB)
   WHERE id(d) = 11111 and id(r) = 11112
   CREATE (d)-[:RelationA {prop: 'value'}]->(r)
   $$) as (a agtype);
   ```
   All other edges are created by direct insertion in the specific edge table 
(using 
[executemany](https://magicstack.github.io/asyncpg/current/api/index.html#asyncpg.connection.Connection.executemany)):
   ```
   INSERT INTO graph_name.RelationA (start_id, end_id, properties)
   VALUES ($1, $2, $3)
   ```
   Where `$1` are the domain_ids, `$2` are the range_ids and `$3` are the 
properties (as json dump).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@age.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to