title: MySQL ALTER TABLE on very large table - is it safe to run it?
body: <p>I have a MySQL database with a MyISAM table with 4 million rows. I update this table about once a week with about 2000 new rows. After updating, I then alter the table like this:</p>
  
  <pre><code>ALTER TABLE x ORDER BY PK DESC
  </code></pre>
  
  <p>I order the table by the primary key field in descending order. This has not given me any problems on my development machine (Windows with 3GB memory).  Three times I have tried it successfully on the production Linux server (with 512MB RAM - and achieving the resulted sorted table in about 6 minutes each time), the last time I tried it I had to stop the query after about 30 minutes and rebuild the database from a backup.</p>
  
  <p>Can a 512MB server cope with that alter statement on such a large table?  I have read that a temporary table is created to perform the ALTER TABLE command.  </p>
  
  <p>Question: Can this alter command be safely run?  What should be the expected time for the alteration of the table?</p>