title: Mysql Insert Large data
body: <p>for now im trying to optimize some codes..</p>
  
  <p>What is a better way to insert a large data into table? </p>
  
  <p>Consider this code is running. </p>
  
  <pre><code>$arrayOfdata = execute query (SELECT c.id FROM table1 ) 
  </code></pre>
  
  <p>getting all the data from table1 storing it to array and inserting it on the table.</p>
  
  <pre><code> private function insertSomeData($arrayOfdata, $other_id){
        foreach($arrayOfdata as $data){
                  INSERT INTO table (
                      other_id,
                      other2_id,
                      is_transfered
                  ) VALUES ('.$other_id.', '.$data['id'].', 0)'
              }
      }
  </code></pre>
  
  <p>i know if it have 500k of data in table1 this code is very slow. so i tried something like this.. i put all in one sql query</p>
  
  <pre><code>INSERT INTO 
  table (
      other_id,
      other2_id,
      is_transfered
  ) 
  SELECT 
      "other_id", c.id, 0 
  FROM table1 
  </code></pre>
  
  <p>I read that to much large of data to insert cause the mysql to slow down or timeout.
  i tried this code on 500k of data in my local computer and it runs well..</p>
  
  <p>is there any way that it will cause a problem if large data will be insert? other ways for faster insert that would not cause the server to use to0 much resources?</p>