I think this line might be the remaining slow part of the process.  On staging, it takes about 10 seconds to execute it and its called twice.  I'm not sure the best way to avoid it, but maybe we could add a column to Message called bulk_id or something.  We could set that to a randomly generated 64 or 128 bit integer when we bulk create them.  Then we could quickly retrieve the exact IDs that were created.