optimization: reduce perl memory footprint when doing SQL queries

also added m5nr dump script