[英]Neo4j Legacy relationship auto-index Slow in cypher query
NODES NODES
1000000 x ({prop:'a'})
1000000 x ({prop:'b'})
1000000 x ({prop:'c'})
NODE SET = ~3MegaNodes 节点集 =〜3MegaNodes
Obs.: prop is not an exclusive atribute. 观察:道具不是排他性的。
RELATIONSHIPS 关系
1000 x [:TYPEA {date:20150301} ]
1000 x [:TYPEA {date:20150228} ]
1000 x [:TYPEA {date:20150227} ]
1000 x [:TYPEA {date:........} ]
1000 x [:TYPEA {date:19000101} ]
1000 x [:TYPEB {date:20150301} ]
1000 x [:TYPEB {date:20150228} ]
1000 x [:TYPEB {date:20150227} ]
1000 x [:TYPEB {date:........} ]
1000 x [:TYPEB {date:19000101} ]
TYPEA = 42062 days x 1 000 rels TYPEA = 42062天x千rel
TYPEA = ~42 000 000 TYPEA =〜42000000
TYPEB = ~42 000 000 TYPEB =〜42000000
RELATIONSHIP SET = ~84 MegaRels 关系集 =〜84 MegaRels
I wanna match the pattern: 我想匹配模式:
MATCH (n1 {prop:'a'}) -[ r1:TYPEA {date:20001231} ]-> (n2 {prop:'b'})
RETURN n2;
Improve by indexing 通过索引改善
My neo4j.properties: 我的neo4j.properties:
relationship_auto_indexing=true
relationship_keys_indexable=date
The cypher query: 密码查询:
START
r1 = relationship:relationship_auto_index('date:20001231')
MATCH (n1 {prop:'a'}) -[r1:TYPEA]-> (n2 {prop:'b'})
RETURN n2;
:) Work fine! :)工作正常!
Now, I wanna match the pattern: 现在,我想匹配模式:
MATCH
(n1 {prop:'a'})
-[ r1:TYPEA {date:20001231} ]->
(n2 {prop:'b'})
-[ r2:TYPEA {date:20001231} ]->
(n3 {prop:'c'})
RETURN n2, n3;
Then I try: 然后我尝试:
START
r1 = relationship:relationship_auto_index('date:20001231'),
r2 = relationship:relationship_auto_index('date:20001231')
MATCH (n1 {prop:'a'}) -[r1:TYPEA]-> (n2 {prop:'b'}) -[r2:TYPEA]-> (n3 {prop:'c'})
RETURN DISTINCT n2, n3;
:( Run Slow. :(运行慢。
Because Cartesian product occurs producing many intermediate results. 因为出现笛卡尔积会产生许多中间结果。 1000 ^ 2. 1000 ^ 2。
On the one hand, is not possible use the same identifier more than once in the query. 一方面,在查询中不能多次使用同一标识符。
On the other hand, Labels index (Schema) do not apply to relationships. 另一方面,标签索引(架构)不适用于关系。
There are hope? 有希望吗? (Release: Neo4j-community-2.2.0) (发布:Neo4j-community-2.2.0)
There are any benefit in relationship legacy indexing when not using the clause start in the query cypher? 不使用查询密码中的子句开始时,关系旧式索引有什么好处?
Thanx 感谢名单
This modify the conceptual query, but worked fine: 这样可以修改概念查询,但效果很好:
START
r = relationship:relationship_auto_index('date:20001231')
WITH [x IN COLLECT(r) WHERE TYPE(x)='TYPEA'] AS cr
UNWIND cr AS r1
MATCH (n1 {prop:'a'}) -[r1]-> (n2 {prop:'b'})
WITH DISTINCT n2, cr
UNWIND cr AS r2
MATCH (n2) -[r2]-> (n3 {prop:'c'})
RETURN DISTINCT n2, n3;
Thx 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.