Parallel execution of single cypher query

Hello, I'm a student using Neo4j and I have a question for you.

Current situation)
I am currently testing the execution speed of a basic Cypher query (N-hop traversal) on Neo4j version 4.4.3, without using the APOC library. There are a lot of reads happening, so I'm expecting it to be faster if the scan runs in parallel.

Question)
If I run a single Cypher query in general without using the APOC library, will the Neo4j server split up the query's tasks (e.g. scan) on its own and run them in parallel? Or does it behave sequentially with only one thread?

I would be really grateful if anyone can let me know.
Thanks.

Hello! Yes, Cypher (even without APOC) will divide up tasks within the query and run as much as it can in parallel. You can see this working by putting either EXPLAIN or PROFILE in front of your query. Hope this helps!

Cheers,
Jennifer

Thank you so much for your reply.

I have one more question.
I want to compare the execution speed of parallel execution and non-parallel execution. Is there a way to disable the parallel execution plan you mentioned or adjust the degree of parallelization?

Thanks.

I have been corrected by a colleague. So, Cypher does not currently run queries multi-threaded. Queries are single-threaded. However, there is an experimental feature for multi-threaded queries!

If you have access to Neo4j Enterprise 5.x, you can configure the new experimental feature and test your query with and without the below prefix to see the difference between multi-threaded and single-threaded.

CYPHER runtime=parallel

Hope this helps!

1 Like

Thank you for your kind response.
It really helped me a lot.

Thanks.

Hi ghlee5084,

if you want to try the experimental feature, you will have to enable it by setting:
internal.cypher.parallel_runtime_support=all
in neo4j.conf.

Experimental features are disabled by default.

Then follow instructions from Jennifer. Query not prefixed with the parallel indication will run single-threaded.
I suggest using the latest Neo4j EE version: experimental features evolve rapidly, and the latter, the better.

Have fun!

Thanks for your help, I will try the latest Neo4j EE version.

Thanks!

Hi @ghlee5084 ,

Just a note to reiterate - this is a capability that is under development and is not ready for production use quite yet - hence it is considered "experimental." As such, you won't find any documentation. Having said that, feel free to give it a try!

Best,

Thanks for the clarification!

Thanks.