I run the following SQL Query on a MySQL platform.
Table A is a table which has a single column (primary key) and 25K rows.
Table B has several columns and 75K rows.
It takes 20 minutes to execute following query. I will be glad if you could help.
INSERT INTO sometable
SELECT A.PrimaryKeyColumn as keyword, 'SomeText', B.*
FROM A, B
WHERE B.PrimaryKeyColumn = CONCAT(A.PrimaryKeyColumn, B.NotUniqueButIndexedColumn);
Run the
SELECTwithout theINSERTto see if the problem is with theSELECTor not.If it is with the
SELECT, follow the MySQL documentation explaining how to optimize queries usingEXPLAIN.If the
SELECTruns fine but theINSERTtakes forever, make sure you don’t have a lot of unnecessary indexes onsometable. Beyond that, you may need to do some MySQL tuning and/or OS tuning (e.g., memory or disk performance) to get a measurable performance boost with theINSERT.