title: MySQL disable & enable keys
body: <p>In my MySQL database,  there is a table which has 2,000,000 records. Now, I would like to insert another 6,000,000 new records into this table.</p>
  
  <p>To speed up the insertion, I though I should use disable/enable keys like following:</p>
  
  <pre><code>ALTER TABLE cars DISABLE KEYS;
  
  INSERT INTO cars ...
  ...
  ...
  INSERT INTO cars ...
  
  ALTER TABLE search_all_values ENABLE KEYS;
  
  OPTIMIZE TABLE cars;
  </code></pre>
  
  <p>But I somehow feel that, the disable/enable keys would make more sense to be used for empty table insertion. </p>
  
  <p>While in my case, I have already 2,000,000 records in the table, when <code>ENABLE KEYS</code>, mysql will re-create all the indexes (including the existing records and new added records) which probably won't produce a efficient data insertion as a whole in my case. <strong>As re-create all the indexes will take long time</strong> and probably so does <code>OPTIMIZE TABLE</code></p>
  
  <p>I would like to ask your opinion about am I right and how can I have a efficent data insertion in my case?</p>