title: How to seed Devise users efficiently?
body: <p>I'm trying to seed about 100,000 users using rake db:seed in my Rails 3 project and it is really slow!</p>
  
  <p>Here's the code sample:</p>
  
  <pre><code># ...
  User.create!(
    :display_name =&gt; "#{title} #{name} #{surname}",
    :email =&gt; "#{name}.#{surname}_#{num}@localtinkers.com",
    :password =&gt; '12341234'
  )
  </code></pre>
  
  <p>It works, but it is <strong>really slow</strong> because for each user:</p>
  
  <ol>
  <li>Devise issues a SELECT statement to find out if the email is already taken.</li>
  <li>A separate INSERT statement is issued.</li>
  </ol>
  
  <p>For other objects I use "<em>ar-extensions</em>" and "<em>activerecord-import</em>" gems as follows:</p>
  
  <pre><code>tags.each do |tag|
    all_tags &lt;&lt; Tag.new(:name =&gt; tag)
  end
  
  Tag.import(all_tags, :validate =&gt; false, :ignore =&gt; true)
  </code></pre>
  
  <p>The above creates just one INSERT statement for all the tags and it works <strong>really fast</strong>, just like MySql database restore from the SQL dump.</p>
  
  <p>But for users I cannot do this because I need Devise to generate encrypted password, salt, etc for each user. Is there a way to generate them on the SQL side or are there other efficient ways of seeding users?</p>
  
  <p>Thank you.</p>