You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@age.apache.org by "xephtar (via GitHub)" <gi...@apache.org> on 2023/02/20 12:48:46 UTC

[GitHub] [age] xephtar opened a new issue, #690: Index advice for hop queries

xephtar opened a new issue, #690:
URL: https://github.com/apache/age/issues/690

   We have 6 types of nodes. There is a relation one relation between them like below
   
   ```
   typeOne -[REL]-> typeTwo
   typeOne -[REL]-> typeThree
   typeOne -[REL]-> typeFour
   typeOne -[REL]-> typeFive
   typeOne -[REL]-> typeSix
   ```
   
   We have a queries. They searchsall typeOne nodes like below query
   ```
   
   MATCH (:typeTwo{value:"searchingValue}) - [:REL*..100]- (node:typeOne) RETURN typeOne.prop
   MATCH (:typeThree{value:"searchingValue}) - [:REL*..100]- (node:typeOne) RETURN typeOne.prop
   MATCH (:typeFour{value:"searchingValue}) - [:REL*..100]- (node:typeOne) RETURN typeOne.prop
   MATCH (:typeFive{value:"searchingValue}) - [:REL*..100]- (node:typeOne) RETURN typeOne.prop
   MATCH (:typeSix{value:"searchingValue}) - [:REL*..100]- (node:typeOne) RETURN typeOne.prop
   ```
   
   It takes too much time to search. We can't search with direction because we want to search each typeOne node who has relations.
   
   How index should we add to make it faster?
   
   We can't change the graph because we can achieve same need with neo4j already.
   We want to move it AGE. Can you help us? How does index work for AGE?


-- 
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-unsubscribe@age.apache.org.apache.org

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


[GitHub] [age] humzakt commented on issue #690: Index advice for hop queries

Posted by "humzakt (via GitHub)" <gi...@apache.org>.
humzakt commented on issue #690:
URL: https://github.com/apache/age/issues/690#issuecomment-1528975732

   Indexing in Apache AGE can help improve the performance of your queries, similar to how indexing works in Neo4j. Since Apache AGE is built on top of PostgreSQL, you can leverage PostgreSQL's native indexing capabilities to create indices on the properties of your vertices.
   
   To speed up your queries, you can create indices on the value property for each of the node types (typeTwo to typeSix). Here's how you can create indices for each node type:
   
   ```
   CREATE INDEX type_two_value_idx ON ag_vertex(typeTwo) USING btree (properties->>'value');
   CREATE INDEX type_three_value_idx ON ag_vertex(typeThree) USING btree (properties->>'value');
   CREATE INDEX type_four_value_idx ON ag_vertex(typeFour) USING btree (properties->>'value');
   CREATE INDEX type_five_value_idx ON ag_vertex(typeFive) USING btree (properties->>'value');
   CREATE INDEX type_six_value_idx ON ag_vertex(typeSix) USING btree (properties->>'value');
   ```
   
   These indices will improve the performance of your queries when searching for nodes based on the value property.
   
   However, it's worth noting that using a variable-length path pattern with a large maximum depth (e.g., [:REL*..100]) can still lead to slow query performance, as it requires traversing a significant portion of the graph. If possible, try to reduce the maximum depth to a smaller value based on your specific use case.
   
   In addition, you can optimize your queries by merging them into a single query using the UNION operator, which can help reduce the overall query execution time:
   
   ```
   MATCH (:typeTwo{value:"searchingValue"}) - [:REL*..100]- (node:typeOne) RETURN node.prop
   UNION
   MATCH (:typeThree{value:"searchingValue2"}) - [:REL*..100]- (node:typeOne) RETURN node.prop
   UNION
   MATCH (:typeFour{value:"searchingValue3"}) - [:REL*..100]- (node:typeOne) RETURN node.prop
   UNION
   MATCH (:typeFive{value:"searchingValue4"}) - [:REL*..100]- (node:typeOne) RETURN node.prop
   UNION
   MATCH (:typeSix{value:"searchingValue5"}) - [:REL*..100]- (node:typeOne) RETURN node.prop;
   
   ```


-- 
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-unsubscribe@age.apache.org

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


[GitHub] [age] jrgemignani commented on issue #690: Index advice for hop queries

Posted by "jrgemignani (via GitHub)" <gi...@apache.org>.
jrgemignani commented on issue #690:
URL: https://github.com/apache/age/issues/690#issuecomment-1451112114

   @xephtar How much is too much time? Too much is rather subjective. Could you put in an EXPLAIN ANALYZE to dump what it is doing?
   
   In general, using a directionless match with variable length edges is an intensive search. Recall that directionless means any edge on a node is a valid path.


-- 
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-unsubscribe@age.apache.org

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


[GitHub] [age] xephtar commented on issue #690: Index advice for hop queries

Posted by "xephtar (via GitHub)" <gi...@apache.org>.
xephtar commented on issue #690:
URL: https://github.com/apache/age/issues/690#issuecomment-1534202291

   Thanks for advices.


-- 
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-unsubscribe@age.apache.org

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


[GitHub] [age] xephtar closed issue #690: Index advice for hop queries

Posted by "xephtar (via GitHub)" <gi...@apache.org>.
xephtar closed issue #690: Index advice for hop queries
URL: https://github.com/apache/age/issues/690


-- 
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-unsubscribe@age.apache.org

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


[GitHub] [age] xephtar commented on issue #690: Index advice for hop queries

Posted by "xephtar (via GitHub)" <gi...@apache.org>.
xephtar commented on issue #690:
URL: https://github.com/apache/age/issues/690#issuecomment-1449436569

   I checked but the given solution is not eligible for us. Giving the direction of relation breaks our hop logic


-- 
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-unsubscribe@age.apache.org

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


[GitHub] [age] rafsun42 commented on issue #690: Index advice for hop queries

Posted by "rafsun42 (via GitHub)" <gi...@apache.org>.
rafsun42 commented on issue #690:
URL: https://github.com/apache/age/issues/690#issuecomment-1444840868

   @xephtar Have you checked out this issue #628 yet? It looks like the problem being discusses is similar to yours. 


-- 
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-unsubscribe@age.apache.org

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


[GitHub] [age] jrgemignani commented on issue #690: Index advice for hop queries

Posted by "jrgemignani (via GitHub)" <gi...@apache.org>.
jrgemignani commented on issue #690:
URL: https://github.com/apache/age/issues/690#issuecomment-1451119095

   Btw, the VLE component itself doesn't use indexes but, the surrounding logic might. I would need a dataset to look at to get a better idea.


-- 
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-unsubscribe@age.apache.org

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