As a suggestion to optimize this further, I would use "upsert_all" to insert all countries with one sql query and delegate to another job the download of the flags. The one job per country seems like a giant N+1 query to me. Obviously, there is no need to optimize so much if theses imports happen only from time to time.