[bug 979872] Speed up indexing

* pull data from mysql in batches rather than one-at-a-dumb-time
* increase bulk index size from 80 to 200
* move the reset_queries() thing out of the inner loop

This reduces the time it takes to index 57000 docs locally from 5m49s to
3m49s. The reset_queries() bit won't help production, but the other two
will. Having said that, production is very different from my local
machine, so the results may be more or less dramatic.