How we optimized our Email Batch API by using Rails bulk inserts with MySQL and how to calculate the auto-incrementing IDs for records, given MySQL does not support a RETURNING clause.