def bulk_insert_ums(ums: List[UserMessageLite]) -> None:
    "\n    Doing bulk inserts this way is much faster than using Django,\n    since we don't have any ORM overhead.  Profiling with 1000\n    users shows a speedup of 0.436 -> 0.027 seconds, so we're\n    talking about a 15x speedup.\n    "
    if (not ums):
        return
    vals = [(um.user_profile_id, um.message_id, um.flags) for um in ums]
    query = SQL('\n        INSERT into\n            zerver_usermessage (user_profile_id, message_id, flags)\n        VALUES %s\n    ')
    with connection.cursor() as cursor:
        execute_values(cursor.cursor, query, vals)
Doing bulk inserts this way is much faster than using Django,
since we don't have any ORM overhead.  Profiling with 1000
users shows a speedup of 0.436 -> 0.027 seconds, so we're
talking about a 15x speedup.
def bulk_insert_ums(ums: List[UserMessageLite]) -> None:
    "\n    Doing bulk inserts this way is much faster than using Django,\n    since we don't have any ORM overhead.  Profiling with 1000\n    users shows a speedup of 0.436 -> 0.027 seconds, so we're\n    talking about a 15x speedup.\n    "
    if (not ums):
        return
    vals = [(um.user_profile_id, um.message_id, um.flags) for um in ums]
    query = SQL('\n        INSERT into\n            zerver_usermessage (user_profile_id, message_id, flags)\n        VALUES %s\n    ')
    with connection.cursor() as cursor:
        execute_values(cursor.cursor, query, vals)