panosfol commented on issue #983:
URL: https://github.com/apache/age/issues/983#issuecomment-1629945291

   Of course! Here is the complete query plan trees of the above queries:
   
   Query: ```MATCH (charlie {name: 'Charlie 
Sheen'})-[:ACTED_IN*1..3]-(movie:Movie)
   RETURN movie.title```
   My plan: 
   ``` 
   Nested Loop  (cost=0.01..150165.77 rows=2853333 width=32)
      Join Filter: age_match_vle_terminal_edge(charlie.id, movie.id, 
_age_default_alias_0.edges)
      ->  Nested Loop  (cost=0.01..342.40 rows=8000 width=40)
            ->  Append  (cost=0.00..182.39 rows=8 width=8)
                  ->  Seq Scan on _ag_label_vertex charlie_1  (cost=0.00..0.00 
rows=1 width=8)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on "Person" charlie_2  (cost=0.00..26.05 rows=1 
width=8)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on "Movie" charlie_3  (cost=0.00..26.05 rows=1 
width=8)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on label1 charlie_4  (cost=0.00..26.05 rows=1 
width=8)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on label2 charlie_5  (cost=0.00..26.05 rows=1 
width=8)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on label3 charlie_6  (cost=0.00..26.05 rows=1 
width=8)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on label4 charlie_7  (cost=0.00..26.05 rows=1 
width=8)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on label5 charlie_8  (cost=0.00..26.05 rows=1 
width=8)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
            ->  Function Scan on age_vle _age_default_alias_0  
(cost=0.01..10.01 rows=1000 width=32)
      ->  Materialize  (cost=0.00..26.05 rows=1070 width=40)
            ->  Seq Scan on "Movie" movie  (cost=0.00..20.70 rows=1070 width=40)
   ```
   
   Current Plan: 
   ``` 
   Nested Loop  (cost=0.01..168381.05 rows=3200000 width=32)
      Join Filter: age_match_vle_terminal_edge(charlie.id, movie.id, 
_age_default_alias_0.edges)
      ->  Nested Loop  (cost=0.01..356.05 rows=8000 width=40)
            ->  Append  (cost=0.00..196.04 rows=8 width=8)
                  ->  Seq Scan on _ag_label_vertex charlie_1  (cost=0.00..0.00 
rows=1 width=8)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on "Person" charlie_2  (cost=0.00..28.00 rows=1 
width=8)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on "Movie" charlie_3  (cost=0.00..28.00 rows=1 
width=8)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on label1 charlie_4  (cost=0.00..28.00 rows=1 
width=8)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on label2 charlie_5  (cost=0.00..28.00 rows=1 
width=8)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on label3 charlie_6  (cost=0.00..28.00 rows=1 
width=8)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on label4 charlie_7  (cost=0.00..28.00 rows=1 
width=8)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on label5 charlie_8  (cost=0.00..28.00 rows=1 
width=8)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
            ->  Function Scan on age_vle _age_default_alias_0  
(cost=0.01..10.01 rows=1000 width=32)
      ->  Materialize  (cost=0.00..28.00 rows=1200 width=40)
            ->  Seq Scan on "Movie" movie  (cost=0.00..22.00 rows=1200 width=40)
   ```
   
   
   
   Query: ```MATCH p = (actor {name: 'Charlie Sheen'})-[:ACTED_IN*2]-(co_actor)
   RETURN relationships(p)```
   My plan: 
   ```
    Nested Loop  (cost=0.01..1199103.45 rows=19975998 width=32)
      Join Filter: age_match_vle_terminal_edge(actor.id, co_actor.id, 
_age_default_alias_0.edges)
      ->  Nested Loop  (cost=0.01..342.40 rows=8000 width=72)
            ->  Append  (cost=0.00..182.39 rows=8 width=40)
                  ->  Seq Scan on _ag_label_vertex actor_1  (cost=0.00..0.00 
rows=1 width=40)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on "Person" actor_2  (cost=0.00..26.05 rows=1 
width=40)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on "Movie" actor_3  (cost=0.00..26.05 rows=1 
width=40)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on label1 actor_4  (cost=0.00..26.05 rows=1 
width=40)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on label2 actor_5  (cost=0.00..26.05 rows=1 
width=40)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on label3 actor_6  (cost=0.00..26.05 rows=1 
width=40)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on label4 actor_7  (cost=0.00..26.05 rows=1 
width=40)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
                  ->  Seq Scan on label5 actor_8  (cost=0.00..26.05 rows=1 
width=40)
                        Filter: (properties @> agtype_build_map('name'::text, 
'"Charlie Sheen"'::agtype))
            ->  Function Scan on age_vle _age_default_alias_0  
(cost=0.01..10.01 rows=1000 width=32)
      ->  Materialize  (cost=0.00..219.81 rows=7491 width=40)
            ->  Append  (cost=0.00..182.36 rows=7491 width=40)
                  ->  Seq Scan on _ag_label_vertex co_actor_1  (cost=0.00..0.00 
rows=1 width=40)
                  ->  Seq Scan on "Person" co_actor_2  (cost=0.00..20.70 
rows=1070 width=40)
                  ->  Seq Scan on "Movie" co_actor_3  (cost=0.00..20.70 
rows=1070 width=40)
                  ->  Seq Scan on label1 co_actor_4  (cost=0.00..20.70 
rows=1070 width=40)
                  ->  Seq Scan on label2 co_actor_5  (cost=0.00..20.70 
rows=1070 width=40)
                  ->  Seq Scan on label3 co_actor_6  (cost=0.00..20.70 
rows=1070 width=40)
                  ->  Seq Scan on label4 co_actor_7  (cost=0.00..20.70 
rows=1070 width=40)
                  ->  Seq Scan on label5 co_actor_8  (cost=0.00..20.70 
rows=1070 width=40)
   ```
   Current Plan: 
   ```
   Nested Loop  (cost=0.01..1344732.01 rows=22402664 width=32)
      Join Filter: age_match_vle_terminal_edge(actor.id, co_actor.id, 
_age_default_alias_0.edges)
      ->  Append  (cost=0.00..196.00 rows=8401 width=40)
            ->  Seq Scan on _ag_label_vertex co_actor_1  (cost=0.00..0.00 
rows=1 width=40)
            ->  Seq Scan on "Person" co_actor_2  (cost=0.00..22.00 rows=1200 
width=40)
            ->  Seq Scan on "Movie" co_actor_3  (cost=0.00..22.00 rows=1200 
width=40)
            ->  Seq Scan on label1 co_actor_4  (cost=0.00..22.00 rows=1200 
width=40)
            ->  Seq Scan on label2 co_actor_5  (cost=0.00..22.00 rows=1200 
width=40)
            ->  Seq Scan on label3 co_actor_6  (cost=0.00..22.00 rows=1200 
width=40)
            ->  Seq Scan on label4 co_actor_7  (cost=0.00..22.00 rows=1200 
width=40)
            ->  Seq Scan on label5 co_actor_8  (cost=0.00..22.00 rows=1200 
width=40)
      ->  Materialize  (cost=0.01..396.05 rows=8000 width=72)
            ->  Nested Loop  (cost=0.01..356.05 rows=8000 width=72)
                  ->  Append  (cost=0.00..196.04 rows=8 width=40)
                        ->  Seq Scan on _ag_label_vertex actor_1  
(cost=0.00..0.00 rows=1 width=40)
                              Filter: (properties @> 
agtype_build_map('name'::text, '"Charlie Sheen"'::agtype))
                        ->  Seq Scan on "Person" actor_2  (cost=0.00..28.00 
rows=1 width=40)
                              Filter: (properties @> 
agtype_build_map('name'::text, '"Charlie Sheen"'::agtype))
                        ->  Seq Scan on "Movie" actor_3  (cost=0.00..28.00 
rows=1 width=40)
                              Filter: (properties @> 
agtype_build_map('name'::text, '"Charlie Sheen"'::agtype))
                        ->  Seq Scan on label1 actor_4  (cost=0.00..28.00 
rows=1 width=40)
                              Filter: (properties @> 
agtype_build_map('name'::text, '"Charlie Sheen"'::agtype))
                        ->  Seq Scan on label2 actor_5  (cost=0.00..28.00 
rows=1 width=40)
                              Filter: (properties @> 
agtype_build_map('name'::text, '"Charlie Sheen"'::agtype))
                        ->  Seq Scan on label3 actor_6  (cost=0.00..28.00 
rows=1 width=40)
                              Filter: (properties @> 
agtype_build_map('name'::text, '"Charlie Sheen"'::agtype))
                        ->  Seq Scan on label4 actor_7  (cost=0.00..28.00 
rows=1 width=40)
                              Filter: (properties @> 
agtype_build_map('name'::text, '"Charlie Sheen"'::agtype))
                        ->  Seq Scan on label5 actor_8  (cost=0.00..28.00 
rows=1 width=40)
                              Filter: (properties @> 
agtype_build_map('name'::text, '"Charlie Sheen"'::agtype))
                  ->  Function Scan on age_vle _age_default_alias_0  
(cost=0.01..10.01 rows=1000 width=32)
   ```
   
   
   Query: ```MATCH (wallstreet:Movie {title: 'Wall Street'})-[*0..1]-(x)
   RETURN x```
   My plan: 
   ```
    Nested Loop  (cost=0.01..125080.91 rows=2497000 width=32)
      Join Filter: age_match_vle_terminal_edge(wallstreet.id, x.id, 
_age_default_alias_0.edges)
      ->  Append  (cost=0.00..182.36 rows=7491 width=40)
            ->  Seq Scan on _ag_label_vertex x_1  (cost=0.00..0.00 rows=1 
width=40)
            ->  Seq Scan on "Person" x_2  (cost=0.00..20.70 rows=1070 width=40)
            ->  Seq Scan on "Movie" x_3  (cost=0.00..20.70 rows=1070 width=40)
            ->  Seq Scan on label1 x_4  (cost=0.00..20.70 rows=1070 width=40)
            ->  Seq Scan on label2 x_5  (cost=0.00..20.70 rows=1070 width=40)
            ->  Seq Scan on label3 x_6  (cost=0.00..20.70 rows=1070 width=40)
            ->  Seq Scan on label4 x_7  (cost=0.00..20.70 rows=1070 width=40)
            ->  Seq Scan on label5 x_8  (cost=0.00..20.70 rows=1070 width=40)
      ->  Materialize  (cost=0.01..51.06 rows=1000 width=40)
            ->  Nested Loop  (cost=0.01..46.06 rows=1000 width=40)
                  ->  Seq Scan on "Movie" wallstreet  (cost=0.00..26.05 rows=1 
width=8)
                        Filter: (properties @> agtype_build_map('title'::text, 
'"Wall Street"'::agtype))
                  ->  Function Scan on age_vle _age_default_alias_0  
(cost=0.01..10.01 rows=1000 width=32)
   ```
   Current plan: 
   ```
    Nested Loop  (cost=0.01..140263.18 rows=2800333 width=32)
      Join Filter: age_match_vle_terminal_edge(wallstreet.id, x.id, 
_age_default_alias_0.edges)
      ->  Append  (cost=0.00..196.00 rows=8401 width=40)
            ->  Seq Scan on _ag_label_vertex x_1  (cost=0.00..0.00 rows=1 
width=40)
            ->  Seq Scan on "Person" x_2  (cost=0.00..22.00 rows=1200 width=40)
            ->  Seq Scan on "Movie" x_3  (cost=0.00..22.00 rows=1200 width=40)
            ->  Seq Scan on label1 x_4  (cost=0.00..22.00 rows=1200 width=40)
            ->  Seq Scan on label2 x_5  (cost=0.00..22.00 rows=1200 width=40)
            ->  Seq Scan on label3 x_6  (cost=0.00..22.00 rows=1200 width=40)
            ->  Seq Scan on label4 x_7  (cost=0.00..22.00 rows=1200 width=40)
            ->  Seq Scan on label5 x_8  (cost=0.00..22.00 rows=1200 width=40)
      ->  Materialize  (cost=0.01..53.01 rows=1000 width=40)
            ->  Nested Loop  (cost=0.01..48.01 rows=1000 width=40)
                  ->  Seq Scan on "Movie" wallstreet  (cost=0.00..28.00 rows=1 
width=8)
                        Filter: (properties @> agtype_build_map('title'::text, 
'"Wall Street"'::agtype))
                  ->  Function Scan on age_vle _age_default_alias_0  
(cost=0.01..10.01 rows=1000 width=32)
   ```
   
   
   Query: ```MATCH p = (michael {name: 'Michael Douglas'})-->()
   RETURN p```
   My plan: 
   ```
   Hash Join  (cost=264.38..677.64 rows=3970 width=32)
      Hash Cond: (_age_default_alias_1.id = _age_default_alias_0.end_id)
      ->  Append  (cost=0.00..182.36 rows=7491 width=40)
            ->  Seq Scan on _ag_label_vertex _age_default_alias_1_1  
(cost=0.00..0.00 rows=1 width=40)
            ->  Seq Scan on "Person" _age_default_alias_1_2  (cost=0.00..20.70 
rows=1070 width=40)
            ->  Seq Scan on "Movie" _age_default_alias_1_3  (cost=0.00..20.70 
rows=1070 width=40)
            ->  Seq Scan on label1 _age_default_alias_1_4  (cost=0.00..20.70 
rows=1070 width=40)
            ->  Seq Scan on label2 _age_default_alias_1_5  (cost=0.00..20.70 
rows=1070 width=40)
            ->  Seq Scan on label3 _age_default_alias_1_6  (cost=0.00..20.70 
rows=1070 width=40)
            ->  Seq Scan on label4 _age_default_alias_1_7  (cost=0.00..20.70 
rows=1070 width=40)
            ->  Seq Scan on label5 _age_default_alias_1_8  (cost=0.00..20.70 
rows=1070 width=40)
      ->  Hash  (cost=263.06..263.06 rows=106 width=96)
            ->  Hash Join  (cost=182.49..263.06 rows=106 width=96)
                  Hash Cond: (_age_default_alias_0.start_id = michael.id)
                  ->  Append  (cost=0.00..69.61 rows=2641 width=56)
                        ->  Seq Scan on _ag_label_edge _age_default_alias_0_1  
(cost=0.00..0.00 rows=1 width=56)
                        ->  Seq Scan on "ACTED_IN" _age_default_alias_0_2  
(cost=0.00..18.80 rows=880 width=56)
                        ->  Seq Scan on "DIRECTED" _age_default_alias_0_3  
(cost=0.00..18.80 rows=880 width=56)
                        ->  Seq Scan on "FATHER_OF" _age_default_alias_0_4  
(cost=0.00..18.80 rows=880 width=56)
                  ->  Hash  (cost=182.39..182.39 rows=8 width=40)
                        ->  Append  (cost=0.00..182.39 rows=8 width=40)
                              ->  Seq Scan on _ag_label_vertex michael_1  
(cost=0.00..0.00 rows=1 width=40)
                                    Filter: (properties @> 
agtype_build_map('name'::text, '"Michael Douglas"'::agtype))
                              ->  Seq Scan on "Person" michael_2  
(cost=0.00..26.05 rows=1 width=40)
                                    Filter: (properties @> 
agtype_build_map('name'::text, '"Michael Douglas"'::agtype))
                              ->  Seq Scan on "Movie" michael_3  
(cost=0.00..26.05 rows=1 width=40)
                                    Filter: (properties @> 
agtype_build_map('name'::text, '"Michael Douglas"'::agtype))
                              ->  Seq Scan on label1 michael_4  
(cost=0.00..26.05 rows=1 width=40)
                                    Filter: (properties @> 
agtype_build_map('name'::text, '"Michael Douglas"'::agtype))
                              ->  Seq Scan on label2 michael_5  
(cost=0.00..26.05 rows=1 width=40)
                                    Filter: (properties @> 
agtype_build_map('name'::text, '"Michael Douglas"'::agtype))
                              ->  Seq Scan on label3 michael_6  
(cost=0.00..26.05 rows=1 width=40)
                                    Filter: (properties @> 
agtype_build_map('name'::text, '"Michael Douglas"'::agtype))
                              ->  Seq Scan on label4 michael_7  
(cost=0.00..26.05 rows=1 width=40)
                                    Filter: (properties @> 
agtype_build_map('name'::text, '"Michael Douglas"'::agtype))
                              ->  Seq Scan on label5 michael_8  
(cost=0.00..26.05 rows=1 width=40)
                                    Filter: (properties @> 
agtype_build_map('name'::text, '"Michael Douglas"'::agtype))
   ```
   Current plan: 
   ```
   Hash Join  (cost=283.32..760.35 rows=4873 width=32)
      Hash Cond: (_age_default_alias_1.id = _age_default_alias_0.end_id)
      ->  Append  (cost=0.00..196.00 rows=8401 width=40)
            ->  Seq Scan on _ag_label_vertex _age_default_alias_1_1  
(cost=0.00..0.00 rows=1 width=40)
            ->  Seq Scan on "Person" _age_default_alias_1_2  (cost=0.00..22.00 
rows=1200 width=40)
            ->  Seq Scan on "Movie" _age_default_alias_1_3  (cost=0.00..22.00 
rows=1200 width=40)
            ->  Seq Scan on label1 _age_default_alias_1_4  (cost=0.00..22.00 
rows=1200 width=40)
            ->  Seq Scan on label2 _age_default_alias_1_5  (cost=0.00..22.00 
rows=1200 width=40)
            ->  Seq Scan on label3 _age_default_alias_1_6  (cost=0.00..22.00 
rows=1200 width=40)
            ->  Seq Scan on label4 _age_default_alias_1_7  (cost=0.00..22.00 
rows=1200 width=40)
            ->  Seq Scan on label5 _age_default_alias_1_8  (cost=0.00..22.00 
rows=1200 width=40)
      ->  Hash  (cost=281.87..281.87 rows=116 width=96)
            ->  Hash Join  (cost=196.14..281.87 rows=116 width=96)
                  Hash Cond: (_age_default_alias_0.start_id = michael.id)
                  ->  Append  (cost=0.00..73.66 rows=2911 width=56)
                        ->  Seq Scan on _ag_label_edge _age_default_alias_0_1  
(cost=0.00..0.00 rows=1 width=56)
                        ->  Seq Scan on "ACTED_IN" _age_default_alias_0_2  
(cost=0.00..19.70 rows=970 width=56)
                        ->  Seq Scan on "DIRECTED" _age_default_alias_0_3  
(cost=0.00..19.70 rows=970 width=56)
                        ->  Seq Scan on "FATHER_OF" _age_default_alias_0_4  
(cost=0.00..19.70 rows=970 width=56)
                  ->  Hash  (cost=196.04..196.04 rows=8 width=40)
                        ->  Append  (cost=0.00..196.04 rows=8 width=40)
                              ->  Seq Scan on _ag_label_vertex michael_1  
(cost=0.00..0.00 rows=1 width=40)
                                    Filter: (properties @> 
agtype_build_map('name'::text, '"Michael Douglas"'::agtype))
                              ->  Seq Scan on "Person" michael_2  
(cost=0.00..28.00 rows=1 width=40)
                                    Filter: (properties @> 
agtype_build_map('name'::text, '"Michael Douglas"'::agtype))
                              ->  Seq Scan on "Movie" michael_3  
(cost=0.00..28.00 rows=1 width=40)
                                    Filter: (properties @> 
agtype_build_map('name'::text, '"Michael Douglas"'::agtype))
                              ->  Seq Scan on label1 michael_4  
(cost=0.00..28.00 rows=1 width=40)
                                    Filter: (properties @> 
agtype_build_map('name'::text, '"Michael Douglas"'::agtype))
                              ->  Seq Scan on label2 michael_5  
(cost=0.00..28.00 rows=1 width=40)
                                    Filter: (properties @> 
agtype_build_map('name'::text, '"Michael Douglas"'::agtype))
                              ->  Seq Scan on label3 michael_6  
(cost=0.00..28.00 rows=1 width=40)
                                    Filter: (properties @> 
agtype_build_map('name'::text, '"Michael Douglas"'::agtype))
                              ->  Seq Scan on label4 michael_7  
(cost=0.00..28.00 rows=1 width=40)
                                    Filter: (properties @> 
agtype_build_map('name'::text, '"Michael Douglas"'::agtype))
                              ->  Seq Scan on label5 michael_8  
(cost=0.00..28.00 rows=1 width=40)
                                    Filter: (properties @> 
agtype_build_map('name'::text, '"Michael Douglas"'::agtype))
   ```
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to