Reordering independent MATCH patterns in ArcadeDB leads to a 33.4x runtime gap
I found two result-equivalent ArcadeDB query formulations whose measured runtime differs substantially on the attached graph. The intended difference between the formulations is a pattern-order variant.
I am reporting the observed runtime/profile difference without assigning it to a specific ArcadeDB component.
ArcadeDB Version: Docker image arcadedata/arcadedb:latest
Operating System: Linux Docker container
Installation Method: Docker image arcadedata/arcadedb:latest
API/Driver: ArcadeDB HTTP OpenCypher endpoint
Steps to reproduce
- Load the attached graph setup file into an empty disposable ArcadeDB database:
reproducer_graph.cypher.txt
while IFS= read -r stmt; do
curl -sS -u root:password \
-H 'Content-Type: application/json' \
-d "{\"language\":\"opencypher\",\"command\":\"${stmt//\"/\\\"}\"}" \
http://localhost:2480/api/v1/command/graph
done < reproducer_graph.cypher.txt
- Verify the graph size:
MATCH (n) RETURN count(n) AS nodes;
-- nodes: 128
MATCH ()-[r]->() RETURN count(r) AS relationships;
-- relationships: 67
- Run the fast query:
PROFILE
MATCH (n0)
WITH n0
UNWIND [1868710224] AS a0
UNWIND [517248469, -1472958097, 1525636158] AS a1
MATCH (n1 :L1)<-[r0 :T4]-(n2 :L0 :L1)<-[r1 :T1]-(n3), (n4 :L3)
WHERE (((r1.k43) > -2019129302) AND ((r0.id) <> (r1.id)))
WITH a0, (r0.k57) AS a2
ORDER BY a0
RETURN 0 AS a3;
- Run the slow query:
PROFILE
MATCH (n0)
WITH n0
UNWIND [1868710224] AS a0
UNWIND [517248469, -1472958097, 1525636158] AS a1
MATCH (n4 :L3), (n1 :L1)<-[r0 :T4]-(n2 :L0 :L1)<-[r1 :T1]-(n3)
WHERE (((r1.k43) > -2019129302) AND ((r0.id) <> (r1.id)))
WITH a0, (r0.k57) AS a2
ORDER BY a0
RETURN 0 AS a3;
Expected behavior
The two queries are intended to be result-equivalent. On the same graph, I would expect comparable execution time, or at least not an order-of-magnitude runtime gap, between these two formulations.
Actual behavior
Repeated replay confirmed that the two queries returned the same result rows and reported a large runtime gap.
| Metric |
Fast query |
Slow query |
| Query form |
one result-equivalent pattern-order formulation |
reordered result-equivalent pattern-order formulation |
| Median runtime |
11.206 ms |
374.813 ms |
| Runtime ratio |
1.000x |
33.446x |
| Runtime delta |
n/a |
363.607 ms |
Reordering independent MATCH patterns in ArcadeDB leads to a 33.4x runtime gap
I found two result-equivalent ArcadeDB query formulations whose measured runtime differs substantially on the attached graph. The intended difference between the formulations is a pattern-order variant.
I am reporting the observed runtime/profile difference without assigning it to a specific ArcadeDB component.
ArcadeDB Version: Docker image
arcadedata/arcadedb:latestOperating System: Linux Docker container
Installation Method: Docker image
arcadedata/arcadedb:latestAPI/Driver: ArcadeDB HTTP OpenCypher endpoint
Steps to reproduce
reproducer_graph.cypher.txt
Expected behavior
The two queries are intended to be result-equivalent. On the same graph, I would expect comparable execution time, or at least not an order-of-magnitude runtime gap, between these two formulations.
Actual behavior
Repeated replay confirmed that the two queries returned the same result rows and reported a large runtime gap.