我正在测试将neo4j从3.0.4升级到3.4.7,以前在321毫秒内返回的查询现在会挂起并且永远不会返回。
我不使用任何索引或约束。
说明看起来有些不同,但非常相似
我无法发布个人资料,因为我已经等待了大约3个小时才能将其返回。...
这是一个小安装,大约有5万条记录。
数据是家谱数据,所以关系繁重。查询的可变长度关系部分通常会减慢查询速度,在这种情况下,长度最多可以为18。
我做了很少的香草升级,只需要更改neo4j.conf中的升级和shell参数即可使它工作。
有什么想法吗?
3.0.4解释
neo4j-sh (?)$ explain match (c:Person)-[:IS_WHAKAPAPA_FOR]->(tenant:Tenant)
> where tenant.id = 'TRONR' and not((:Person)-[:HAS_PARENT]->(c))
> match (t:Person)-[:IS_WHAKAPAPA_FOR]->(tenant)
> where t.tupunaId is not null
> with c, tenant, t
> match (c)-[:HAS_PARENT*]->(t)
> return count(c);
+--------------------------------------------+
| No data returned, and nothing was changed. |
+--------------------------------------------+
582 ms
Compiler CYPHER 3.0
Planner COST
Runtime INTERPRETED
+-----------------------+----------------+------------------------------------------------+-----------------------------------+
| Operator | Estimated Rows | Variables | Other |
+-----------------------+----------------+------------------------------------------------+-----------------------------------+
| +ProduceResults | 13 | count(c) | count(c) |
| | +----------------+------------------------------------------------+-----------------------------------+
| +EagerAggregation | 13 | count(c) | |
| | +----------------+------------------------------------------------+-----------------------------------+
| +Expand(Into) | 168 | anon[17] -- anon[135], anon[222], c, t, tenant | (c)-[:IS_WHAKAPAPA_FOR]->(tenant) |
| | +----------------+------------------------------------------------+-----------------------------------+
| +AntiSemiApply | 534 | anon[135], anon[222], t, tenant -- c | |
| |\ +----------------+------------------------------------------------+-----------------------------------+
| | +Filter | 2835 | anon[89], anon[98], c | anon[89]:Person |
| | | +----------------+------------------------------------------------+-----------------------------------+
| | +Expand(All) | 2835 | anon[89], anon[98] -- c | (c)<-[:HAS_PARENT]-() |
| | | +----------------+------------------------------------------------+-----------------------------------+
| | +Argument | 2134 | c | |
| | +----------------+------------------------------------------------+-----------------------------------+
| +Filter | 2134 | anon[135], anon[222], c, t, tenant | c:Person |
| | +----------------+------------------------------------------------+-----------------------------------+
| +VarLengthExpand(All) | 2134 | anon[222], c -- anon[135], t, tenant | (t)-[:HAS_PARENT*]->(c) |
| | +----------------+------------------------------------------------+-----------------------------------+
| +Filter | 1607 | anon[135], t, tenant | t:Person AND hasProp(t.tupunaId) |
| | +----------------+------------------------------------------------+-----------------------------------+
| +Expand(All) | 3213 | anon[135], t -- tenant | (tenant)<-[:IS_WHAKAPAPA_FOR]-(t) |
| | +----------------+------------------------------------------------+-----------------------------------+
| +Filter | 0 | tenant | tenant.id == { AUTOSTRING0} |
| | +----------------+------------------------------------------------+-----------------------------------+
| +NodeByLabelScan | 3 | tenant | :Tenant |
+-----------------------+----------------+------------------------------------------------+-----------------------------------+
Total database accesses: ?
3.4.7解释
neo4j-sh (?)$ explain match (c:Person)-[:IS_WHAKAPAPA_FOR]->(tenant:Tenant)
> where tenant.id = 'TRONR' and not((:Person)-[:HAS_PARENT]->(c))
> match (t:Person)-[:IS_WHAKAPAPA_FOR]->(tenant)
> where t.tupunaId is not null
> with c, tenant, t
> match (c)-[:HAS_PARENT*]->(t)
> return count(c);
+--------------------------------------------+
| No data returned, and nothing was changed. |
+--------------------------------------------+
2 ms
Compiler CYPHER 3.4
Planner COST
Runtime INTERPRETED
Runtime version 3.4
+-----------------------+----------------+------------------------------------------------+--------------------------------------+
| Operator | Estimated Rows | Variables | Other |
+-----------------------+----------------+------------------------------------------------+--------------------------------------+
| +ProduceResults | 13 | count(c) | |
| | +----------------+------------------------------------------------+--------------------------------------+
| +EagerAggregation | 13 | count(c) | |
| | +----------------+------------------------------------------------+--------------------------------------+
| +Expand(Into) | 168 | anon[135] -- anon[17], anon[222], c, t, tenant | (t)-[:IS_WHAKAPAPA_FOR]->(tenant) |
| | +----------------+------------------------------------------------+--------------------------------------+
| +Filter | 534 | anon[17], anon[222], c, t, tenant | EXISTS(t.tupunaId); t:Person |
| | +----------------+------------------------------------------------+--------------------------------------+
| +VarLengthExpand(All) | 1067 | anon[222], t -- anon[17], c, tenant | (c)-[:HAS_PARENT*]->(t) |
| | +----------------+------------------------------------------------+--------------------------------------+
| +AntiSemiApply | 803 | anon[17], tenant -- c | |
| |\ +----------------+------------------------------------------------+--------------------------------------+
| | +Filter | 4268 | NODE89, REL98, c | ` NODE89`:Person |
| | | +----------------+------------------------------------------------+--------------------------------------+
| | +Expand(All) | 4268 | NODE89, REL98 -- c | (c)<-[ REL98:HAS_PARENT]-( NODE89) |
| | | +----------------+------------------------------------------------+--------------------------------------+
| | +Argument | 3213 | c | |
| | +----------------+------------------------------------------------+--------------------------------------+
| +Filter | 3213 | anon[17], c, tenant | c:Person |
| | +----------------+------------------------------------------------+--------------------------------------+
| +Expand(All) | 3213 | anon[17], c -- tenant | (tenant)<-[:IS_WHAKAPAPA_FOR]-(c) |
| | +----------------+------------------------------------------------+--------------------------------------+
| +Filter | 0 | tenant | tenant.id = $` AUTOSTRING0` |
| | +----------------+------------------------------------------------+--------------------------------------+
| +NodeByLabelScan | 3 | tenant | :Tenant |
+-----------------------+----------------+------------------------------------------------+--------------------------------------+
Total database accesses: ?
编辑 如果我限制可变长度查询,则可以获取配置文件并将其与3.0.4版本进行比较: 3.0.4
neo4j-sh (?)$ profile match (c:Person)-[:IS_WHAKAPAPA_FOR]->(tenant:Tenant)
> where tenant.id = 'TRONR' and not((:Person)-[:HAS_PARENT]->(c))
> match (t:Person)-[:IS_WHAKAPAPA_FOR]->(tenant)
> where t.tupunaId is not null
> with c, tenant, t
> match (c)-[:HAS_PARENT*]->(t)
> return count(c);
+----------+
| count(c) |
+----------+
| 40607 |
+----------+
1 row
630 ms
Compiler CYPHER 3.0
Planner COST
Runtime INTERPRETED
+-----------------------+----------------+-------+---------+------------------------------------------------+-----------------------------------+
| Operator | Estimated Rows | Rows | DB Hits | Variables | Other |
+-----------------------+----------------+-------+---------+------------------------------------------------+-----------------------------------+
| +ProduceResults | 13 | 1 | 0 | count(c) | count(c) |
| | +----------------+-------+---------+------------------------------------------------+-----------------------------------+
| +EagerAggregation | 13 | 1 | 0 | count(c) | |
| | +----------------+-------+---------+------------------------------------------------+-----------------------------------+
| +Expand(Into) | 168 | 40607 | 23138 | anon[17] -- anon[135], anon[222], c, t, tenant | (c)-[:IS_WHAKAPAPA_FOR]->(tenant) |
| | +----------------+-------+---------+------------------------------------------------+-----------------------------------+
| +AntiSemiApply | 534 | 40205 | 0 | anon[135], anon[222], t, tenant -- c | |
| |\ +----------------+-------+---------+------------------------------------------------+-----------------------------------+
| | +Filter | 2835 | 0 | 17514 | anon[89], anon[98], c | anon[89]:Person |
| | | +----------------+-------+---------+------------------------------------------------+-----------------------------------+
| | +Expand(All) | 2835 | 17514 | 75233 | anon[89], anon[98] -- c | (c)<-[:HAS_PARENT]-() |
| | | +----------------+-------+---------+------------------------------------------------+-----------------------------------+
| | +Argument | 2134 | 57719 | 0 | c | |
| | +----------------+-------+---------+------------------------------------------------+-----------------------------------+
| +Filter | 2134 | 57719 | 57719 | anon[135], anon[222], c, t, tenant | c:Person |
| | +----------------+-------+---------+------------------------------------------------+-----------------------------------+
| +VarLengthExpand(All) | 2134 | 57719 | 115439 | anon[222], c -- anon[135], t, tenant | (t)-[:HAS_PARENT*]->(c) |
| | +----------------+-------+---------+------------------------------------------------+-----------------------------------+
| +Filter | 1607 | 1 | 56432 | anon[135], t, tenant | t:Person AND hasProp(t.tupunaId) |
| | +----------------+-------+---------+------------------------------------------------+-----------------------------------+
| +Expand(All) | 3213 | 28216 | 28217 | anon[135], t -- tenant | (tenant)<-[:IS_WHAKAPAPA_FOR]-(t) |
| | +----------------+-------+---------+------------------------------------------------+-----------------------------------+
| +Filter | 0 | 1 | 3 | tenant | tenant.id == { AUTOSTRING0} |
| | +----------------+-------+---------+------------------------------------------------+-----------------------------------+
| +NodeByLabelScan | 3 | 3 | 4 | tenant | :Tenant |
+-----------------------+----------------+-------+---------+------------------------------------------------+-----------------------------------+
Total database accesses: 373699
3.4.7
neo4j> profile match (c:Person)-[:IS_WHAKAPAPA_FOR]->(tenant:Tenant)
where tenant.id = 'TRONR' and not((:Person)-[:HAS_PARENT]->(c))
match (t:Person)-[:IS_WHAKAPAPA_FOR]->(tenant)
where t.tupunaId is not null
with c, tenant, t
match (c)-[:HAS_PARENT*1..10]->(t)
return count(c);
+-----------------------------------------------------------------------------------------+
| Plan | Statement | Version | Planner | Runtime | Time | DbHits | Rows |
+-----------------------------------------------------------------------------------------+
| "PROFILE" | "READ_ONLY" | "CYPHER 3.4" | "COST" | "INTERPRETED" | 4490 | 0 | 1 |
+-----------------------------------------------------------------------------------------+
+-----------------------+----------------+---------+---------+-----------+----------------------------------------------+-------------------------------------------------+
| Operator | Estimated Rows | Rows | DB Hits | Cache H/M | Identifiers | Other |
+-----------------------+----------------+---------+---------+-----------+----------------------------------------------+-------------------------------------------------+
| +ProduceResults | 13 | 1 | 0 | 0/0 | count(c) | 0.0; 3.4; 3.4 |
| | +----------------+---------+---------+-----------+----------------------------------------------+-------------------------------------------------+
| +EagerAggregation | 13 | 1 | 0 | 0/0 | count(c) | 0.0 |
| | +----------------+---------+---------+-----------+----------------------------------------------+-------------------------------------------------+
| +Expand(Into) | 168 | 3449 | 4 | 0/0 | tenant, t, anon[135], anon[17], c, anon[222] | 0.0; (t)-[anon[135]:IS_WHAKAPAPA_FOR]->(tenant) |
| | +----------------+---------+---------+-----------+----------------------------------------------+-------------------------------------------------+
| +Filter | 534 | 3449 | 1347753 | 0/0 | tenant, t, anon[17], c, anon[222] | 0.0; t:Person |
| | +----------------+---------+---------+-----------+----------------------------------------------+-------------------------------------------------+
| +VarLengthExpand(All) | 1067 | 1344304 | 2354092 | 0/0 | tenant, t, anon[17], c, anon[222] | 0.0; (c)-[anon[222]:HAS_PARENT*..10]->(t) |
| | +----------------+---------+---------+-----------+----------------------------------------------+-------------------------------------------------+
| +AntiSemiApply | 803 | 14602 | 0 | 0/0 | anon[17], c, tenant | 0.0 |
| |\ +----------------+---------+---------+-----------+----------------------------------------------+-------------------------------------------------+
| | +Filter | 4268 | 0 | 13614 | 0/0 | NODE89, REL98, c | 0.0; ` NODE89`:Person |
| | | +----------------+---------+---------+-----------+----------------------------------------------+-------------------------------------------------+
| | +Expand(All) | 4268 | 13614 | 41830 | 0/0 | NODE89, REL98, c | 0.0; (c)<-[ REL98:HAS_PARENT]-( NODE89) |
| | | +----------------+---------+---------+-----------+----------------------------------------------+-------------------------------------------------+
| | +Argument | 3213 | 28216 | 0 | 0/0 | c | 0.0 |
| | +----------------+---------+---------+-----------+----------------------------------------------+-------------------------------------------------+
| +Filter | 3213 | 28216 | 28216 | 0/0 | anon[17], c, tenant | 0.0; c:Person |
| | +----------------+---------+---------+-----------+----------------------------------------------+-------------------------------------------------+
| +Expand(All) | 3213 | 28216 | 28217 | 0/0 | anon[17], c, tenant | 0.0; (tenant)<-[anon[17]:IS_WHAKAPAPA_FOR]-(c) |
| | +----------------+---------+---------+-----------+----------------------------------------------+-------------------------------------------------+
| +Filter | 0 | 1 | 3 | 0/0 | tenant | 0.0; tenant.id = $` AUTOSTRING0` |
| | +----------------+---------+---------+-----------+----------------------------------------------+-------------------------------------------------+
| +NodeByLabelScan | 3 | 3 | 4 | 0/0 | tenant | 0.0; :Tenant |
+-----------------------+----------------+---------+---------+-----------+----------------------------------------------+-------------------------------------------------+
+----------+
| count(c) |
+----------+
| 3449 |
+----------+
1 row available after 4490 ms, consumed after another 0 ms
答案 0 :(得分:0)
在neo4j社区页面-https://community.neo4j.com/t/upgrade-kills-query/1889/5
的帮助下,我设法找到了一种解决方法