I kinda wondered how long it would take...

mysql> insert into foo_new select * from foo;
Query OK, 60000000 rows affected (3 hours 3 min 52.94 sec)
Records: 60000000  Duplicates: 0  Warnings: 0

Not bad.

(Note: Those are not actual table names.)

Posted by jzawodn at April 01, 2004 04:13 PM

Reader Comments
# Jon said:

Yeah, but what's the row size?

on April 1, 2004 04:27 PM
# Marc said:

A metric like that doesn't seem to provide much usable information. I can do 60M rows of one column on a 18 Ghz box and a terabyte of memory. What's the table type? What's the Column specification? How many indicies on the table? What are the specs of the box? Other info that would make this a meaningful number?

I've seen 7M rows take 32 hours (!?) to insert, but that was on a crappy 500 MHz sparc II w/2G, IDE, a few indices, etc., even using MySQL's extended insert...

on April 1, 2004 05:13 PM
# Donny said:

Jeremy,
We had a similiar problem and we found a decent solution. Doing a select * from foo, no matter how big or small it is with 60 million rows will take some time. Especially since it won't use an index.

So figure out if you can put a where clause in there somehow that uses an index. And then do multiple inserts, like:
insert into foo_new select * from foo where bar < 5
insert into foo_new select * from foo where bar =5

But if you can't find one that will get you at least 20% of the rows than it's not worth your time.

Donny

on April 1, 2004 09:29 PM
# justin said:

what's wrong with:

cd /data/mysql
cp foo.frm foo_new.frm
cp foo.MYD foo_new.MYD
cp foo.MYI foo_new.MYI
chown mysql foo_new.*

or am i missing the point completely?

on April 2, 2004 01:12 AM
# Donny said:

Justin - Unless you shutdown MySQL when you copy via the way you mentioned, the table will automatically repair itself. And with 60,000,000 rows, I can imagine it will take a while, depending on how many indexes.

Last week, I had a similiar problem, with a table wih 135,000,000 rows, it was only about 15 gigs of just data, and about 4.5 gigs of index and it took about 4 hours to rebuild.

Donny

on April 2, 2004 05:41 AM
# justin said:

A-ha! i didn't know about that table auto-repairing stuff. thanks.

on April 2, 2004 05:48 AM
# Dominik said:

"A metric like that doesn't seem to provide much usable information. I can do 60M rows of one column on a 18 Ghz box and a terabyte of memory. What's the table type? What's the Column specification? How many indicies on the table? What are the specs of the box? Other info that would make this a meaningful number?"

I think this post should not be a benchmark. It's more the fact that the insert took a while and now after more than 3,5 hours its over.
When my database does a job like this one, I would be happy to if its done.

Greetings
Dominik

on April 2, 2004 08:58 AM
# Marc said:

"When my database does a job like this one, I would be happy to if its done."

And boy was I happy when the 32 hour insert was done...

Phew.

on April 2, 2004 04:24 PM
# justin said:

off topic: why are yahoo pushing "penis enlargment pill" adverts , when i'm browsing around their French regional directory? I wouldn't mind ads to do with France, but tacky penis adverts? Come on yahoo - you can do way better.

http://dir.yahoo.com/Regional/Countries/France/Regions/Nord_Pas_de_Calais/Departments/Nord/Cities/Lille/Business_and_Shopping/Business_to_Business/

on April 3, 2004 01:25 AM
# Anuj Goyal said:

hey guys, I know this will sound ludicrous, but I know of a very specialized database that can perform this type of "copy" operation (2 million rows, each row is about 50 bytes) in about 10 seconds (on a thinkpad 240x 500Mhz PIII, 192 MB of RAM).

In fact, on a reasonably sized box (lots of CPU, lots of RAM), it can insert about 4 TeraBytes of Data in 20 minutes. Sounds unbelievable right?!!!!

What if I told you that this database was being funded by the US Army? ....

:)

--Anuj

on April 3, 2004 02:21 PM
# R Walker said:

3hrs is a long time to kill at the water cooler :)

on April 3, 2004 02:46 PM
Disclaimer: The opinions expressed here are mine and mine alone. My current, past, or previous employers are not responsible for what I write here, the comments left by others, or the photos I may share. If you have questions, please contact me. Also, I am not a journalist or reporter. Don't "pitch" me.

 

Privacy: I do not share or publish the email addresses or IP addresses of anyone posting a comment here without consent. However, I do reserve the right to remove comments that are spammy, off-topic, or otherwise unsuitable based on my comment policy. In a few cases, I may leave spammy comments but remove any URLs they contain.