Unix Technical Forum

How to move whole tables fast

This is a discussion on How to move whole tables fast within the MySQL forums, part of the Database Server Software category; --> I have two MySQL databases on different servers and computers. I often need to move a number of tables ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 08:17 AM
Rune
 
Posts: n/a
Default How to move whole tables fast

I have two MySQL databases on different servers and computers. I often need
to move a number of tables from one database to the other database. So far I've
been using "mysqldump" to make a backup, and "mysql" to load the backup in
the other DB, but the amount of data is fairly large and it is very slow. Is
there a faster method? I though of simply copying the database files, but
the two database servers are not the same version, so I don't know how that
will work.

Thanks
/Rune


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 08:17 AM
Giuseppe Maxia
 
Posts: n/a
Default Re: How to move whole tables fast

Rune wrote:
> I have two MySQL databases on different servers and computers. I often need
> to move a number of tables from one database to the other database. So far I've
> been using "mysqldump" to make a backup, and "mysql" to load the backup in
> the other DB, but the amount of data is fairly large and it is very slow. Is
> there a faster method? I though of simply copying the database files, but
> the two database servers are not the same version, so I don't know how that
> will work.
>
> Thanks
> /Rune
>
>


To speed up a dump, you can use

mysqldump --opt -u USER -pPASSWORD database_name table_name > file.sql

That way, mysqldump will try all the known tricks to minimize the rebuild time.
http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html

If you were already using that option and it's still too slow for your needs, you may
want to consider replication instead of dumping tables.
http://dev.mysql.com/doc/refman/5.0/en/replication.html

Copying tables is a tricky business. To get a clean copy, you should stop the server,
copy the tables and restart the server. Or you could flush the tables, lock them all
and copy with the server still running. mysqlhotcopy will do the dirty work for you
http://dev.mysql.com/doc/refman/5.0/...qlhotcopy.html
However, it works only for MyISAM tables, and only on Unix and Netware systems.

Table formats are backward compatible, i.e. a table from a 4.0 server will be read
and understood by a 4.1 server, but not the other way around.

ciao
gmax

--
_ _ _ _
(_|| | |(_|>< The Data Charmer
_|
http://datacharmer.blogspot.com/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 08:17 AM
Bill Karwin
 
Posts: n/a
Default Re: How to move whole tables fast

"Rune" <slam@slam.slam> wrote in message
news:43d0d796$0$15791$14726298@news.sunsite.dk...
>I have two MySQL databases on different servers and computers. I often need
>to move a number of tables from one database to the other database. So far
>I've been using "mysqldump" to make a backup, and "mysql" to load the
>backup in the other DB, but the amount of data is fairly large and it is
>very slow. Is there a faster method?


According to the docs, LOAD DATA INFILE is up to 20x faster than running a
lot of insert statements from a script. You could dump the table(s) with
SELECT...INTO OUTFILE, transport that data dump to the other server, and
load it with LOAD DATA INFILE.

Read about LOAD DATA INFILE here:
http://dev.mysql.com/doc/refman/5.0/en/load-data.html

There are further tips on performance enhancements to loading data here:
http://dev.mysql.com/doc/refman/5.0/...ert-speed.html
(e.g. use ALTER TABLE...DISABLE KEYS and SET FOREIGN_KEY_CHECKS=0 before the
data load, then re-enable them afterwards).

Regards,
Bill K.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:42 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com