Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Old 08-01-2007, 12:13 PM MySql bulk insert
Junior Talker

Posts: 2
Name: Mauro
Trades: 0
Hi all,

I wonder if any of you did bulk inserts of 50 - 100k records on mysql. I really would like to know some tips on the best way to do this (for performance) , i.e. if you used any etl tools or just sp.

Thanks in advance!
__________________
Database programmer.

Please login or register to view this content. Registration is FREE
maguero is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-01-2007, 05:51 PM Re: MySql bulk insert
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
No tools will give you more performance, as your bottleneck is your server...
what you can do to lower the server load is either to use transactions, or use "insert delayed".

Transaction: [ http://dev.mysql.com/doc/refman/4.1/...-commands.html ]
If your db support it (mysql may need a specific backend to support it, depending of mysql version), you start a transaction by sending "start tansaction", then send all your insert one after the other, and finish the transaction with a "commit" or a "rollback".
This method have the great advantage that the db knows that it don't have to re-compute the indexes before you do the commit.

insert delayed: [ http://dev.mysql.com/doc/refman/4.1/...t-delayed.html ]
This is a special mysql command, that let you give a hint on the db about the importance of the insert.
An insert delayed will always be processed when the db will not be occupied doing something else, it have a low priority comparing to standard insert/update.

Quote:
Another major benefit of using INSERT DELAYED is that inserts from many clients are bundled together and written in one block. This is much faster than performing many separate inserts.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 08-02-2007, 09:16 PM Re: MySql bulk insert
Junior Talker

Posts: 2
Name: Mauro
Trades: 0
Quote:
Originally Posted by tripy View Post
No tools will give you more performance, as your bottleneck is your server...
what you can do to lower the server load is either to use transactions, or use "insert delayed".

Transaction: [ http://dev.mysql.com/doc/refman/4.1/...-commands.html ]
If your db support it (mysql may need a specific backend to support it, depending of mysql version), you start a transaction by sending "start tansaction", then send all your insert one after the other, and finish the transaction with a "commit" or a "rollback".
This method have the great advantage that the db knows that it don't have to re-compute the indexes before you do the commit.

insert delayed: [ http://dev.mysql.com/doc/refman/4.1/...t-delayed.html ]
This is a special mysql command, that let you give a hint on the db about the importance of the insert.
An insert delayed will always be processed when the db will not be occupied doing something else, it have a low priority comparing to standard insert/update.
Thanks very much tripy for your reply.
I will try with this technique and see the performance. It sounds like it should do much better with it.

Thanks!
__________________
Database programmer.

Please login or register to view this content. Registration is FREE
maguero is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to MySql bulk insert
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11775 seconds with 12 queries