for now im trying to optimize some codes..
What is a better way to insert a large data into table?
Consider this code is running.
$arrayOfdata = execute query (SELECT c.id FROM table1 )
getting all the data from table1 storing it to array and inserting it on the table.
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)'
}
}
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
INSERT INTO
table (
other_id,
other2_id,
is_transfered
)
SELECT
"other_id", c.id, 0
FROM table1
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..
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?