ksheroz commented on issue #1219:
URL: https://github.com/apache/age/issues/1219#issuecomment-1724030759

   > Some observations:
   > 
   > * The same query with `CREATE` instead of `MERGE` works just fine
   > 
   > ```
   > SELECT * FROM cypher('xyz', 
   > $$
   > MATCH (x:Label1{arr:[1,2,3,4]})
   > CREATE (y:Label2{key1:2, key2:x.arr, key3:3})
   > RETURN y
   > $$) as (a agtype);
   > ```
   > 
   >  * The same query with `MERGE` twice also works just fine
   > 
   > ```
   > SELECT * FROM cypher('xyz', 
   > $$
   > MATCH (x:Label1{arr:[1,2,3,4]})
   > MERGE (y:Label2{key1:2, key2:x.arr, key3:3})
   > MERGE (z:Label2{key1:2, key2:x.arr, key3:3})
   > RETURN y
   > $$) as (a agtype);
   > ```
   > 
   > Next, let us analyze the Query Plan Trees for `MATCH`-`MERGE`, 
`MATCH`-`CREATE`, and `MATCH`-`MERGE`-`MERGE` queries.
   > 
   > * Query plan for `MATCH`-`MERGE`:
   > 
   > ```
   >  Custom Scan (Cypher Merge)  (cost=0.00..0.00 rows=0 width=32)
   >    ->  Subquery Scan on _age_default_alias_previous_cypher_clause  
(cost=0.00..86.02 rows=1 width=32)
   >          ->  Nested Loop Left Join  (cost=0.00..86.00 rows=1 width=96)
   >                Join Filter: (z.properties @> 
agtype_build_map('key1'::text, '2'::agtype, 'key2'::text, 
agtype_access_operator(VARIADIC ARRAY[_agtype_build_vertex(x.id, 
_label_name('18201'::oid, x.id), x.
   > properties), '"arr"'::agtype]), 'key3'::text, '3'::agtype))
   >                ->  Seq Scan on "Label1" x  (cost=0.00..31.00 rows=1 
width=40)
   >                      Filter: (properties @> agtype_build_map('arr'::text, 
agtype_build_list('1'::agtype, '2'::agtype, '3'::agtype, '4'::agtype)))
   >                ->  Seq Scan on "Label2" z  (cost=0.00..28.00 rows=1200 
width=64)
   > (7 rows)
   > ```
   > 
   > * Query plan for `MATCH`-`CREATE`:
   > 
   > ```
   >  Custom Scan (Cypher Create)  (cost=0.00..0.00 rows=0 width=32)
   >    ->  Subquery Scan on _age_default_alias_previous_cypher_clause  
(cost=0.00..31.03 rows=1 width=32)
   >          ->  Seq Scan on "Label1" x  (cost=0.00..31.02 rows=1 width=160)
   >                Filter: (properties @> agtype_build_map('arr'::text, 
agtype_build_list('1'::agtype, '2'::agtype, '3'::agtype, '4'::agtype)))
   > (4 rows)
   > ```
   > 
   > * Query plan for `MATCH`-`MERGE`-`MERGE`:
   > 
   > ```
   >  Custom Scan (Cypher Merge)  (cost=0.00..0.00 rows=0 width=32)
   >    ->  Subquery Scan on _age_default_alias_previous_cypher_clause  
(cost=0.00..49.02 rows=1 width=32)
   >          ->  Nested Loop Left Join  (cost=0.00..49.01 rows=1 width=160)
   >                Join Filter: (z.properties @> 
agtype_build_map('key1'::text, '2'::agtype, 'key2'::text, 
agtype_access_operator(VARIADIC 
ARRAY[_age_default_alias_previous_cypher_clause_1.x, '"arr"'::agtype
   > ]), 'key3'::text, '3'::agtype))
   >                ->  Custom Scan (Cypher Merge)  (cost=0.00..0.00 rows=0 
width=64)
   >                      ->  Subquery Scan on 
_age_default_alias_previous_cypher_clause_1  (cost=0.00..86.02 rows=1 width=64)
   >                            ->  Nested Loop Left Join  (cost=0.00..86.01 
rows=1 width=96)
   >                                  Join Filter: (y.properties @> 
agtype_build_map('key1'::text, '2'::agtype, 'key2'::text, 
agtype_access_operator(VARIADIC ARRAY[_agtype_build_vertex(x.id, 
_label_name('1820
   > 1'::oid, x.id), x.properties), '"arr"'::agtype]), 'key3'::text, 
'3'::agtype))
   >                                  ->  Seq Scan on "Label1" x  
(cost=0.00..31.00 rows=1 width=40)
   >                                        Filter: (properties @> 
agtype_build_map('arr'::text, agtype_build_list('1'::agtype, '2'::agtype, 
'3'::agtype, '4'::agtype)))
   >                                  ->  Seq Scan on "Label2" y  
(cost=0.00..28.00 rows=1200 width=64)
   >                ->  Seq Scan on "Label2" z  (cost=0.00..28.00 rows=1200 
width=64)
   > (12 rows)
   > ```
   > 
   > Cannot draw a conclusion
   > 
   > @ksheroz What do you think?
   
   It seems like that the `Join Filter` is the issue here. Any idea which 
function triggers it?


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