HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Is it better to use AUTOCOMMIT = 0

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
autocommitusebetter

Problem

Is it better to use (for perfomance tuning) AUTOCOMMIT = 0 before bulk inserts of data in MySQL, if the insert query looks like

INSERT INTO SomeTable (column1, column2) VALUES (val1,val2),(val3,val4),... ?

Solution

According to the documentation, AUTOCOMMIT should be turned off in InnoDB.

When importing data into InnoDB, turn off autocommit mode, because it performs a log flush to disk for every insert.

When doing bulk inserts into tables with auto-increment columns, set innodb_autoinc_lock_mode to 2 instead of the default value 1

Context

StackExchange Database Administrators Q#42704, answer score: 7

Revisions (0)

No revisions yet.