I stumbled upon the solution by messing around with my code.
It turns out that if I call createNode
without specifying the node ID, then it works perfectly well.
I was specifying the node ID because, since the API allowed it, it was convenient to have the node IDs match the IDs from the input file.
Guess at the underlying reason: the nodes are probably stored in a contiguous array indexed by their ID. Most IDs in my input file are small (4 digits), but some can be 12 digits long. So when I tried to insert one of those, Neo4j would write a gigabytes long array to disk just to put that node at the end. Maybe someone can confirm this. It is surprising that this behavior doesn't seem to be documented in the Neo4j API documentation for this method.