title: Rails rake task incredible slow
body: <p>I wrote a rake task in rails to update my user database with a <code>gender</code> value. All it should do is loop through my users and update the gender attribute with a value that I get from a "gender detection" gem (which works well).</p>
  
  <p>The rake task runs for minutes now although I only have a few dozens of records in my database:</p>
  
  <pre><code>require 'gender_detector'
  
  namespace :user do
    desc 'Assign gender to all users'
    task :genderize =&gt; :environment do
  
      User.all.each do |user|
        gd = GenderDetector.new(:case_sensitive =&gt; false)
        gender = gd.get_gender(user.firstname)
  
        sql = "UPDATE users SET gender = '#{gender}' WHERE id = #{user.id}"
        ActiveRecord::Base.connection.execute(sql)
      end
  
    end
  end
  </code></pre>
  
  <p>what do I do wrong?</p>