Add batching to MySQL upsert query