3

I read the following on this page

http://dev.mysql.com/doc/mysql/en/server-system-variables.html

bulk_insert_buffer_size MyISAM uses a special tree-like cache to make bulk inserts faster for INSERT ... SELECT, INSERT ... VALUES (...), (...), ..., and LOAD DATA INFILE. This variable limits the size of the cache tree in bytes per thread. Setting it to 0 disables this optimization. Note: This cache is used only when adding data to a non-empty table. The default value is 8MB. This variable was added in MySQL 4.0.3. This variable previously was named myisam_bulk_insert_tree_size.

I take this to mean that bulk_insert_buffer_size has no bearing on InnoDB tables, only on MyISAM tables. Is this correct?

RolandoMySQLDBA
185k34 gold badges327 silver badges541 bronze badges
asked Sep 11, 2013 at 7:25

2 Answers 2

8

Yes, you are correct. I wrote about this before: How can I optimize this mySQL table that will need to hold 5+ million rows?

WHen it comes to bulk loading InnoDB tables, one of the most frequently ignored settings to disable is innodb_doublewrite.

InnoDB Architecture

InnoDB Architecture

Please note the double write buffer inside the system tablespace file ibdata1. Every time a 16K page is written to an InnoDB table or transaction log, the page is written to the double wrote buffer first. All you need to do is disable it, load your data, and reenable it.

STEP 01 : Disable Fast Shutdown

mysql -uroot -p... -ANe"SET GLOBAL innodb_fast_shutdown = 0"

STEP 02 : Restart mysql without the double write buffer

service mysql restart --innodb-doublewrite=0

STEP 03 : Load the InnoDB data

STEP 04 : Restart mysql

service mysql restart

CAVEAT

You can disable the foreign key checks and the unique checks as well. Any standard mysqldump will do that for you already.

answered Sep 12, 2013 at 17:47
3
  • unless it is (properly configured) zfs, disabling doublewrite may cause page corruptions (when partial write happens). Commented Mar 1, 2016 at 9:20
  • do not do this, this has been proven to corrupt data! percona.com/blog/2014/05/23/… Commented Apr 8, 2020 at 4:36
  • Hey @MuhammadOmerAslam .I have been recommending this for many years (dba.stackexchange.com/…). I still do this. In fact, I did this for a personal client just 2 months ago. He was reloading a DB Server for Production but was not live. It dramatically cut the reload time by well over 50%. Other than reloading huge amounts of data, you are so right and so is that post you mentioned. I have read that post back then. Yet, I still disable innodb_doublewrite when other means of reloading fast do not work. Commented Apr 9, 2020 at 17:55
1

Yes it only works with MyISAM tables.

For Innodb we need to diable unique_checks and foreign_key_checks using

set unique_checks=0; set foreign_key_checks=0; diable auto_commit.

inserts......

set unique_checks=1; set foreign_key_checks=1; enable auto_commit.

Which improves bulk inserts performance.

answered Sep 12, 2013 at 16:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.