title: How to clean up a 30million record table
body: <p>We have a table on our database that tracks user behavior.
  Basically each page that the user views we track this.</p>
  
  <p>In the table we have the following:</p>
  
  <pre><code>id | user_id | user_ip | page | created_on
  </code></pre>
  
  <p>When a user checks the site from PC and let's say he checks a specific article the system saves under "page" the following "/article/specific/slug" however if the user checks the same page from the mobile version of the website it saves "<a href="http://m.website.com/article/specific/slug" rel="nofollow noreferrer">http://m.website.com/article/specific/slug</a>"</p>
  
  <p>We are looking to change this.</p>
  
  <p>We have added a new field in the database as enum (pc, m) and therefore we want regardless of device to save under "page" always "/article/specific/slug"</p>
  
  <p>One issue is that we now have 30 million records in the past that need to be converted.</p>
  
  <p>Meaning we write a query that checks if "<a href="http://m.website.com" rel="nofollow noreferrer">http://m.website.com</a>" exists update the field removing the "<a href="http://m.website.com" rel="nofollow noreferrer">http://m.website.com</a>" and making the "device" field updated as "m".</p>
  
  <p>Can someone please help with this?</p>