MironAtHome commented on issue #1974:
URL: https://github.com/apache/age/issues/1974#issuecomment-2230034348

   > I restarted the server and tried again with `SET LOCAL 
parallel_leader_participation = off;` and the results are same. So, it clearly 
works.
   > 
   > If you give any direction query runs much much faster and yes seems like 
these two produce idential output. Query 1: 
https://explain.dalibo.com/plan/gc622ba38g91afb1
   > 
   > Query 2: https://explain.dalibo.com/plan/14bd391394c9758c
   
   After studying closely behavior of operators ()-[]-() and ()-[]->() it is 
evident, that data will be presented as following:
   If, for example, one is to create two vertices
   v:Person {name:'Alice'}
   v:Person {name:'Bob'}
   and follows by creating two edges
   Alice-[:knows]->Bob
   and 
   Alice<-[:knows]-Bob
   with the id's assigned as following:
   Alice-id:1
   Bob-id:2
   Edge :knows for the relationship Alice-[:knows]->Bob id 3
   Edge :knows for the relationship Alice<-[:knows]-Bob id 4
   Query
   Match (v1)-[:knows]-(v2)
   Will return the following combination of id's
   Row #1: 1,3,2
   Row #2: 1,4,2
   Row #3: 2,3,1
   Row #4: 2,4,1
   However, if we were to present not id's ( which is really an system values 
used by machine internals ) and produce just the distinct combination of names
   
   Match (v1)-[:knows]-(v2)
   WITH v1.name as Name1, v2.name as Name2
   RETURN DISTINCT Name1, Name2
   ORDER BY Name1 ASC, Name2 ASC
   
   We will get back 
   Alice, Bob
   Bob, Alice
   
   Now, if we were to issue query 
   (v1)-[:knows]->(v2)
   For the id producing query we will get only half the rows
   Row #1: 1,3,2
   Row #2: 2,4,1
   
   However, for the name producing query, there would be no difference.
   
   In other words, 
   (v1)-[:knows]-(v2)
   
   Behaves as 
   (v1)-[:knows]->(v2)
   UNION
   (v1)<-[:knows]-(v2)
   
   To summarise, looking at the last query just one line above, it's 2x the 
number of rows stored, with the same relationship listed twice, except 
switching the sides of the data.
   
   In case producing rows once with relationship going left to right is 
acceptable, query can be expressed as 
   (v1)-[:<edge>]->(v2)
   without losing resolution.
   And finally, if performance of query is essential, it could be of use to 
produce various permutations of data using client?
   
   Hope this helps.


-- 
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