Web Hosting Talk







View Full Version : MYSQL problem in inserting (take much CPU)


jason216
09-15-2004, 08:35 PM
Hi

I want to insert DISTINCT data from a table (contain 7,000,000 records) to another table.
When I try to run the command (see below) in SSH, it is taking much CPU and fill up (90%) the Disk hda7 (/tmp) DMA+.

After an hour time, it is aborted . Nothing inserted to the table.
so its failed to insert.

How can I fix it ?
Thanks


mysql> INSERT INTO insert_table (data) SELECT DISTINCT data FROM get_table GROUP BY data;

farpost
09-15-2004, 09:24 PM
Jason,

if your table is myisam then try it with "INSERT DELAYED":

INSERT DELAYED into insert_table.....

jason216
09-15-2004, 09:52 PM
does it take less CPU or not fill up hda /tmp?

is it fast?

What does it use?

THanks

jbrw
09-16-2004, 02:24 AM
http://dev.mysql.com/doc/mysql/en/INSERT_DELAYED.html

hiryuu
09-16-2004, 04:03 AM
That's not the problem, though -- the select is causing large temp tables to deal with the grouping and distinct requirements. If you really do require those, you may need to use where clauses to slice this into multiple queries.