title: Obfuscating data in postgres
body: <p>I'd like to obfuscate data in specific columns in postgres 9.1.</p>
  
  <p>For instance, I want to give all the people a 'random' first and last name.</p>
  
  <p>I can generate a pool of names to use:</p>
  
  <pre><code>select name_first into first_names from people order by random() limit 500;
  select name_last into last_names from people order by random() limit 500;
  </code></pre>
  
  <p>Both of those queries run in about 400ms (which works fine for me, assuming they only need to run once!)</p>
  
  <p>Using a regular update statement doesn't work - this just does each select once, thus gives all the people the same name:</p>
  
  <pre><code>update people
      SET name_last=(SELECT * from last_names order by random() limit 1),
      name_first=(SELECT * from first_names order by random() limit 1)
      where business_id=1;
  </code></pre>
  
  <p>How can I give each person a randomized name in postgres? I really don't want to do this in Ruby on Rails - I assume a pure SQL approach will be faster. However, speed isn't too much of a concern as I literally have all night for this business case.</p>