Does the driver know if a query is READ or WRITE?

I am using the official JS Neo4j driver with "bolt+routing" and I can see that you can queries using run, writeTransaction or readTransaction. My question is if there is any magic going on in the run method that lets the driver automatically discern if a query is read or write, since it seems to support both, even when sending the queries through a FOLLOWER instance.

If it isn't able to find out if things are read or write, what are the consequences then of that? Do all queries end up executing on the LEADER even if they are read queries or does it slow down performance?

1 Like

The driver does not detect whether your query is read or write. You need to use explicit transactions via readTransaction and writeTransaction. If you just do session.run() on everything, the driver will always route your query to the leader to ensure that it can be answered whether it's read or write, but this will place extra strain on just the leader.

For this reason, the recommendation is to always use bolt+routing and explicit transactions to distribute load.

Much more information on querying clusters here: