(imported from commit 30d5f86209f9c8807516f0440276fafeb6590c1a)
This saves 30 seconds in populate_db runtime on MySQL. (imported from commit 7fe483bf5f32cfa3d09db8ad7a9be79bd0a2a271)
(imported from commit 529fef7dd55bb8a5f4e286f7c896f4b14b0d1b8d)
This cuts the time required to import 38000 messages (with 140000 message receipts) from about 10 minutes to just under 40 seconds on my laptop with sqlite. (imported from commit d53b0d1360408c77f38353b58fbb25875262cb40)