我有一个相当简单的图表。它只有大约 100 个节点和 400 个关系。我正在尝试运行各种密码查询,这些查询根据某些关系的存在对结果进行排名。但是,即使使用小型数据库,这些查询也会超时。谁能确定我的查询存在导致超时的问题?
下面的查询搜索各种模式。如果模式存在,它将对关系应用权重。最后,它结合权重并对结果进行排序,因此具有最高权重(最重要的关系)的节点被优先考虑。
START node=node(1)
MATCH (node)-[a?:REQUIRES]-(thing0)-[?:RELATED]-(stuff)
,(node)-[b?:REQUIRES]-(thing1)-[:RELATED]-(system1)-[:COMPOSITION]-(something1)-[?:VERSION]-(stuff)
,(node)-[c?:REQUIRES]-(thing2)-[:RELATED]-(something2)-[?:VERSION]-(stuff)
,(node)-[d?:REQUIRES]-(thing3)-[:REQUIRES]-(project1)-[:REQUIRES]-(thing6)-[?:RELATED]-(stuff)
,(node)-[e?:REQUIRES]-(thing4)-[:DESCRIBES]-(part)-[:DESCRIBES]-(thing5)-[?:RELATED]-(stuff)
WITH stuff
, count(distinct a)*.15 as shareA
, count(distinct b)*.35 as shareB
, count(distinct c)*.25 as shareC
, count(distinct d)*.10 as shareD
, count(distinct e)*.15 as shareE
WHERE has(stuff.__type__)
AND stuff.__type__='full.namespace.to.stuff'
SET stuff.weight = shareA + shareB + shareC + shareD + shareE
RETURN DISTINCT stuff
ORDER BY stuff.weight DESC