vesoft-inc / nebula

A distributed, fast open-source graph database featuring horizontal scalability and high availability
https://nebula-graph.io
Apache License 2.0
10.82k stars 1.2k forks source link

Performance issues: substantial discrepancy between equivalent queries #5617

Open polyominal opened 1 year ago

polyominal commented 1 year ago

Bug Description

The following two equivalent (as one could verify) queries exhibit a substantial performance difference in their execution times.

Query 1:

MATCH (n1:L5:L1:L2)-[r1]->(n2:L4:L0:L2:L3)-[r2]->(n3:L2:L4:L5:L0:L3), (n4:L3)-[:T2|T0|T1]-(n5)-[r3:T1|T0|T2|T5]->(n4:L3:L1:L5)-[:T0|T1|T2]-(n3), (n6)<-[:T2|T4|T3]-(n2:L0:L5:L2:L4), (n7:L5)-[r4:T4|T2]->(n8:L4)<-[r5:T3]-(n5:L4:L2)<-[r6]-(n9:L2:L5:L3:L4:L0) RETURN *

Query 2:

MATCH (n3:L5:L0)-[:T0|T1|T2]-(n4:L3:L1:L5)<-[r3:T1|T0|T2|T5]-(n5:L4:L2), (n3:L2:L4:L5:L3)<-[r2]-(n2:L0:L2:L5), (n9:L2:L5:L3:L4:L0)-[r6]->(n5), (n6)<-[:T2|T4|T3]-(n2:L4:L0:L3:L5)<-[r1]-(n1:L5:L1:L2), (n4:L3:L5)-[:T2|T0|T1]-(n5:L4)-[r5:T3]->(n8:L4)<-[r4:T4|T2]-(n7:L5) RETURN *

Environments

How To Reproduce

Steps to reproduce the behavior:

  1. Execute the statements in create.log to set up the fresh database.
  2. Run the aforementioned queries.

Expected behavior Given the logical equivalence of the two queries, they should ideally have similar execution times. However, on our test system, the first query finishes within a second, while the second one does not finish even after 30 seconds.

kikimo commented 1 year ago

@polyominal tested on the provided dataset, both of the two queries finished within about 500ms:

(root@nebula) [test]> MATCH (n1:L5:L1:L2)-[r1]->(n2:L4:L0:L2:L3)-[r2]->(n3:L2:L4:L5:L0:L3), (n4:L3)-[:T2|T0|T1]-(n5)-[r3:T1|T0|T2|T5]->(n4:L3:L1:L5)-[:T0|T1|T2]-(n3), (n6)<-[:T2|T4|T3]-(n2:L0:L5:L2:L4), (n7:L5)-[r4:T4|T2]->(n8:L4)<-[r5:T3]-(n5:L4:L2)<-[r6]-(n9:L2:L5:L3:L4:L0) RETURN count(*)
+----------+
| count(*) |
+----------+
| 0        |
+----------+
Got 1 rows (time spent 458.21ms/492.015053ms)

Mon, 03 Jul 2023 11:48:46 CST

(root@nebula) [test]> MATCH (n3:L5:L0)-[:T0|T1|T2]-(n4:L3:L1:L5)<-[r3:T1|T0|T2|T5]-(n5:L4:L2), (n3:L2:L4:L5:L3)<-[r2]-(n2:L0:L2:L5), (n9:L2:L5:L3:L4:L0)-[r6]->(n5), (n6)<-[:T2|T4|T3]-(n2:L4:L0:L3:L5)<-[r1]-(n1:L5:L1:L2), (n4:L3:L5)-[:T2|T0|T1]-(n5:L4)-[r5:T3]->(n8:L4)<-[r4:T4|T2]-(n7:L5) RETURN count(*)
+----------+
| count(*) |
+----------+
| 0        |
+----------+
Got 1 rows (time spent 513.922ms/548.525049ms)

Mon, 03 Jul 2023 11:48:50 CST

(root@nebula) [test]>
(root@nebula) [test]>
kikimo commented 1 year ago

@polyominal same as #5616, some error happend while preparing the data, after correting the error we can successfully reproduce the issue described above, thanks for reporting.