title: Convert a ~800k adjacency list MySQL table to nested set
body: <p>I have a very large MySQL table (840000 records) with a <code>parent_id</code> column only.
  I want to convert it into a nested set design (with <code>left</code>, <code>right</code> columns).</p>
  
  <p>What is the best way to do that in terms of memory, e.g. not keeping all 800k records in RAM.</p>
  
  <p>I have a copy of the table, so it's ok to lock the whole table/database.</p>
  
  <p>The table is ordered, so <code>parent_id</code> &lt; <code>id</code>.</p>