I have some performance issue using a specific Cypher Command.
I look for R nodes not directly connected to a specific set of nodes of type I (Here, nodes with index field at "79" and "4") and I want to maximize the field "score" :
MATCH (r:R), (i0:I { index:"79" }), (i1:I { index:"4" })
WHERE NOT r--i0 AND NOT r--i1
RETURN r.index
ORDER BY r.score DESC
LIMIT 5
The query is executed generally in 1250ms. If I remove the ORDER BY clause, the request time goes down to 130ms. The order clause iterates on nearly 3300 elements.
Any idea how I can speed up that request ? I am sure there is a way to use another syntax to perform this search.
I think it is normal, by removing the ORDER BY , he will return you the 5 first nodes he can match. By adding the ORDER BY, it forces to load all possible matching nodes, depending of the amount of "R" nodes the time will increase.
Now :
Did you "profiled" your query with PROFILE
do you have indexes/constraints on I:index ?
Can you change slightly your query to :
MATCH (r:R), (i0:I { index:"79" }), (i1:I { index:"4" })
WHERE NOT EXISTS((r)--(i0))
AND NOT EXISTS((r)--(i1))
RETURN r.index
ORDER BY r.score DESC
LIMIT 5
Which version do you use? try to update to the latest one, also please share your visual query plan by prefixing your query with `PROFILE``
Change it to:
MATCH (i0:I { index:"79" }), (i1:I { index:"4" })
MATCH (r:R)
WHERE NOT r--i0 AND NOT r--i1
WITH r
ORDER BY r.score DESC
LIMIT 5
RETURN r.index
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.