Just for the record, there is a mistake in this query in the list of tables to ignore. It should be:
$tables_to_ignore = array('xf_import_log','xf_search_index','xf_session','xf_session_admin','xf_attachment_view','xf_session_activity','xf_thread_view');
If you've previously ran this script...