Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gemmadlou/3bc63e37dea48c3b11557a8cbbfb6f35 to your computer and use it in GitHub Desktop.
Save gemmadlou/3bc63e37dea48c3b11557a8cbbfb6f35 to your computer and use it in GitHub Desktop.
Non-blocking and quick database dumps for large databases

How-to

Add --single-transaction and --quick to your mysqldump command.

--single-transaction

sets the isolation mode to REPEATABLE READ and starts a transaction before dumping data. useful for InnoDB tables, dumps the consistent state without blocking any applications.

--quick

retrieves ta row at a time from the server instead of the entire table, buffering it and writing it out.

From the mysldump doc:

To dump large tables, combine the --single-transaction option with the --quick option.

Statements and Performance

Before

mysqldump -h'hostname' -u'username' -p'password' 'livedbname'

  • Dump time: ~6 Min.
  • Website blocked

After

mysqldump -h'hostname' -u'username' -p'password' --single-transaction --quick 'livedbname'

  • Dump time: 3 Min.
  • Website not blocked!

Links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment