我正在努力提高下面的查询速度。她在9秒内返回数据。如果我删除shortestPath,时间会下降到1.5秒。
有谁知道我的查询可能有什么问题或者如何优化shartestPath?
这是一个查询:
MATCH (currentUser:Packer {UUID:'19443'})-[:I_Follow*0..1]->followers-[rf:Has_Backpack|Has_Contribution*0..1]->(e)
Match (e)-[rp:Has_Pocket|Has_Document*0..]->d
Match d-[rn:Say_Thanks|I_Follow|I_Favorite_Follow|I_Favorite*0..1]->a
with distinct currentUser,followers, a, last(rf + rp + rn) as l
Optional match shortestPath(currentUser-[:Has_Group|Has_Shared_To_Collaboration|Hub_Shared|Has_Shared|Has_Backpack|Has_Pocket|Has_Document]->a)
with followers, a, count(a) as num,l<br><br>
OPTIONAL MATCH a-[:Hub_Comments]->()-[rf:Has_Comment]->comments
WITH followers, a, l, collect(comments)[0..3] as coll,count(comments) as totalComments,num
MATCH parent-[l]->a where (num > 0 or a.Permission <> 'Private') with followers, a, parent, l, coll, totalComments order by l.Datecreate desc skip 0 limit 10
Match (owner:Packer {Username:a.Createdby})<br>
return followers, a, parent, l, coll, totalComments, owner
使用个人资料有这些数据:
Operator | Rows | DbHits | Identifiers
Extract (0) | 3731 | 7462 |
PatternMatcher (0) | 3731 | 8386 | parent, a, l |
Filter | 3735 | 7470 | | (a> {} AUTOINT3 OR NOT (Property (a, Permission (10)) == {AUTOSTRING4})) |
Total Accesses database: 23386
版本:2.1.6 节点:175,563 物业:468 402 关系:155,284 关系类型:38 数据库磁盘:780 MB 用法:2 MB