Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-15-2020 07:53 AM
Hi,
I apologise if someone has asked this question out there somewhere, but i've been looking for awhile and cant seem to find the answer as to why my query is so slow.
I am trying to filter a subgraph with a specific start and end point, with certain restrictions on the connecting relationships. My graph is not particularly large (around 40 nodes, 270 relationships). The graph has several parallel edges but I dont think that would be an issue for neo4j.
This is my query:
MATCH paths = (from:COVERAGEAREA{name:'SGPUCAALL'})-[:CONNECTED_TO*]->(to:COVERAGEAREA{name:'PH - Luzon'})
WHERE ANY (r IN relationships(paths) WHERE NOT 'UA' IN r.restrictedMerchants AND r.paymentType in ['Both', 'prepaid'])
RETURN paths
01-15-2020 08:21 AM
have you tried using PROFILE to see which part of the query is slow? just checking what you are trying to do aswell, is it any path (no maximum hop limit) between those two nodes as long as they don't use an edge where the restrictedMerchants is UA and the payment type is Both/prepaid.
01-15-2020 08:30 AM
Hi, philip thanks for your help. Yes you are mostly correct, trying to get the subgraph between 2 points as long as the relationship payment type is either both/prepaid and UA is not in its restrictedmerchants
i have tried prepending profile to the query, but the query itself always crashes without a result
** edits
the relationships between nodes represent a time slot, with around 4 slots between each node
i have reduced the slots/relationships between nodes to 1 and was able to get a result back
when i increase it to 2
01-15-2020 09:17 AM
Hmmmm hard to tell, I will have a think. Have you indexed the coverage area nodes on name? You may want to change your data model to have the slots as nodes and then you can either have nodes for restricted merchants, payment types etc...or keep them as properties on the nodes and index that way? That could potentially effect performance. That is one frustration I have had with Neo4J in general, that you can’t index relationship properties as far as I’m aware. But tbf normally I realise I’m trying to fight a non ideal data model
01-16-2020 02:12 AM
yeah thinking about it now, you are really going to struggle as its basically hitting all the relationships from the nodes and then again to filter. have you tried using any of the path APOC's to help? http://neo4j-contrib.github.io/neo4j-apoc-procedures/3.5/path-finding/path-expander/
01-16-2020 03:19 AM
Hi Philip thanks so much for the help! Unfortunately im unable to convert the slots to nodes as we have a need to perform pathfinding between other nodes using these links. Have limited the number of hops per path and this has improved performance slightly.
Will definitely give apoc & indexing a check. Thanks!
01-16-2020 03:25 AM
no problem, yeah i dont think indexing will help much in this situation as normally helpful for finding the start of your path, but that doesnt seem to be the cost here. Good luck!
All the sessions of the conference are now available online