Add a couple of indexes to the node_history to speed up the query.
Also, when calling with -A (showall) and -n (number of records), lets not read the entire 5 million rows and then throw away everything but the first 20. Takes about an hour. In general this script needs some work. Would also be nice to page through records by specifying an index to start with.
Showing with 32 additions and 2 deletions