1、使用match时,避免使用多个标签。搜索使用了2个标签,同样的事情竟然访问了数据库801次。这是因为Cypher运行了额外的 hasLabel 过滤器。
可以通过使用专门的关系类型来解决这样的问题,比如为他们添加PUBLISHED和DRAFTED关系,然后用关系来找到指定用户的published post。
https://blog.csdn.net/u012666689/article/details/84989213
2、随机给node打标签,多线程查询
3、查询策略
查询1:
PROFILE
MATCH path=(x:Node{value:'曾晓民'})-[*1..3]->(y:Node{value:'前田春子'})
RETURN path
时间:Started streaming 3 records after 18 ms and completed after 67117 ms.
路径:NodeByLabelScan-->Filter-->VarLengthExpand(All)-->Filter-->Projection-->ProduceResults
查询2:
PROFILE
MATCH path=(x)-[*1..3]-(y)
WHERE id(x)=1 and id(y) = 14
RETURN path
时间:Started streaming 3 records after 17 ms and completed after 31588 ms.
路径:NodeByIdSeek-->VarLengthExpand(All)-->Filter-->Project