The problem is.
You had 10M nodes in your db.
You deleted them all, you have 10M empty records on disk.
You don't restart.
You create a node, it is put in record 10.000.001
So you have 10M empty records followed by one used record.
After that happened, a restart won't help you to relocate the node, just to reuse the id's of the 10M deleted nodes.
If you restarted after the big delete, then the node would have been created with record id 0.
I wrote a tool that can take a store and copy it to compact it (currently it doesn't change node-id's though) so this would only be useful for compacting rels.
For your query, this is an all node scan, which goes over all records in the db (and if they are in use loads them and counts them).
For a real-world query you'd do that on a Label, like :Product or :Person. Which should come back instantly even if you have millions of empty records.
this: "Detected incorrectly shut down database, performing recovery.." is just recovery after a hard kill or crash, which is ok, as the transactions are written to and reapplied from the tx-log (WAL).
HTH MIchael