Ensure there is a combined index on {authmap}.uid and {authmap}.module.
function user_update_7019() {
// Check first in case it was already added manually.
if (!db_index_exists('authmap', 'uid_module')) {
db_add_index('authmap', 'uid_module', array(
'uid',
'module',
));
}
}