vladiksun commented on issue #1000: URL: https://github.com/apache/age/issues/1000#issuecomment-1723307224
@jrgemignani Thanks for sharing the PR. I have built that branch to see how it could affect our typical queries. It turns out that for our use cases, we do not see much difference. Usually, our typical queries are like this: ``` select properties from ag_catalog.cypher('test_graph', $$ //EXPLAIN ANALYZE MATCH (start_vertex:`scope` {hidden: false}) WHERE start_vertex.name = 'scope_1' OR start_vertex.name = 'scope_2' OR start_vertex.name = 'scope_3' OR start_vertex.name = 'scope_4' OR start_vertex.name = 'scope_5' OR start_vertex.name = 'scope_6' RETURN { properties: properties(start_vertex), ___edge_reserved: properties(null) } UNION MATCH (from:`scope` {hidden: false}) -[e1:`edges`*0..5 {hidden: false}]->(to1:`role` {hidden: false}) -[e2:`edges`*1..1 {hidden: false, fromCollection: 'role', toCollection: 'permission'}]->(to2:`permission` {hidden: false}) -[e3:`edges`*1..1 {hidden: false, fromCollection: 'permission', toCollection: 'resource'}]->(to3:`resource` {hidden: false}) WHERE from.name = 'scope_1' OR from.name = 'scope_2' OR from.name = 'scope_3' OR from.name = 'scope_4' OR from.name = 'scope_5' OR from.name = 'scope_6' WITH collect({ properties: properties(to1), ___edge_reserved: properties(last(e1)) }) + collect({ properties: properties(to2), ___edge_reserved: properties(last(e2)) }) + collect({ properties: properties(to3), ___edge_reserved: properties(last(e3)) }) as result UNWIND result as result_out RETURN DISTINCT result_out LIMIT 1000 $$) as (properties ag_catalog.agtype); ``` As you can see we use only one table (e_label) for edges and structures like ``` {hidden: false, fromCollection: 'role', toCollection: 'permission'} ``` improve the execution time because there is a call to a GIN index that cuts unnecessary edges. That also helps simplify backend logic. So, such a query: ``` select properties from ag_catalog.cypher('test_graph', $$ //EXPLAIN ANALYZE MATCH (from:`domain` {hidden: false})-[any_edge:`edges`*1..10 {hidden: false, fromCollection: 'domain', toCollection: 'domain', relation: 'managed'}]->(to:`domain` {hidden: false, id: 'domain_root_1'}) WITH from, any_edge, to, head(any_edge) AS edge_check_in, head(any_edge) AS edge_result_in RETURN DISTINCT { properties: properties(from), ___edge_reserved: properties(edge_result_in) } LIMIT 1000 $$) as (properties ag_catalog.agtype); ``` works even faster than the version with lots of edge tables. ``` select properties from ag_catalog.cypher('test_graph', $$ //EXPLAIN ANALYZE MATCH (from:`domain` {hidden: false})-[any_edge:`E_DOMAIN_MANAGED_DOMAIN`*1..10 {hidden: false}]->(to:`domain` {hidden: false, id: 'domain_root_1'}) WITH from, any_edge, to, head(any_edge) AS edge_check_in, head(any_edge) AS edge_result_in RETURN DISTINCT { properties: properties(from), ___edge_reserved: properties(edge_result_in) } LIMIT 1000 $$) as (properties ag_catalog.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: dev-unsubscr...@age.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org