Make g_msgids call more performant.

Previously, we'd load *all* the g_msgids for a given account before filtering
them. This makes sense in cases where the in_ parameter is stupidly large
(which it sometimes can be). But in, say, deduplicate_message_object_creation,
this function is called with len(in_) == 1. In that case, doing this adds
hundreds of milliseconds to the time it takes to commit each message.