inserting large quantity of data into mysql table
Dump the source data into a file:

SELECT  a.id,  b.id INTO OUTFILE '/tmp/result.txt' FROM `src` a INNER JOIN src b  WHERE a.id &lt;&gt; b.id

Tune MySQL for large writes:

innodb_flush_log_at_trx_commit=2
innodb_log_file_size=2G



See how to change the log size


Start a pipe to split results.txt in chunks

pt-fifo-split --lines 1000000 /tmp/result.txt


(pt-fifo-split is a part of Percona Toolkit)
Load the dump

while [ -e /tmp/pt-fifo-split ]; do mysql -u &lt;user&gt; -p&lt;pass&gt; -e "LOAD DATA INFILE '/tmp/pt-fifo-split' INTO TABLE tgt" &lt;tgt db&gt;; done


(if you have problem with "File '/tmp/pt-fifo-split' not found", try  this solution )