I implemented my new scheme and running time went from 9 minutes to 24 SECONDS. I liked this approach so much I decided to generalize it as ActiveRecord::Base.transform. Sample usage:
# if users don't have names, give them a random one NAMES = ['Adam', 'Ethan', 'Patrick'] User.transform(:name, :conditions => 'name is null').each do |i| i.name = NAMES[rand * NAMES.length] end
via gurge.com
Really interesting use of temp tables here.