Why MySQL’s –quick Option Isn’t Default: Performance Tradeoffs Explained for Database Developers


2 views

Contrary to what many developers assume, the --quick option is actually enabled by default through the --opt flag in modern MySQL versions. The confusion stems from documentation samples that explicitly include it:

# Common mysqldump example showing explicit --quick
mysqldump --quick --databases mydb > backup.sql

While --quick prevents memory overload by not caching the entire result set, there are scenarios where disabling it makes sense:

  • When dumping small databases where caching improves speed
  • When network latency is extremely high between client and server
  • When working with complex joins that benefit from local caching

Here's how to test performance differences:

# Time a quick dump
time mysqldump --quick mydb > quick.sql

# Time a standard dump
time mysqldump --skip-quick mydb > standard.sql

# Compare memory usage
/usr/bin/time -v mysqldump --quick mydb > /dev/null
/usr/bin/time -v mysqldump --skip-quick mydb > /dev/null

For production environments:

# Best practice for large databases
mysqldump --single-transaction --quick --skip-lock-tables \
  --routines --triggers mydb > backup.sql

# Alternative for small databases on fast connections
mysqldump --skip-quick --compress mydb | gzip > backup.sql.gz

The default behavior represents MySQL's compromise between memory efficiency and network efficiency. Understanding this helps developers make informed choices for their specific use cases.


While examining mysqldump documentation, you'll notice the --quick option which is actually enabled by default through --opt, but this isn't immediately obvious from the documentation. This option tells mysqldump to retrieve rows one at a time rather than loading the entire result set into memory.


# Basic mysqldump with quick option (redundant since it's included in --opt)
mysqldump --quick -u username -p database_name > backup.sql

The reason it's not documented as a default option is historical. Earlier MySQL versions didn't include it in --opt, and the documentation maintains backward compatibility. The --opt flag (which is enabled by default) includes multiple optimizations:

  • --add-drop-table
  • --add-locks
  • --create-options
  • --disable-keys
  • --extended-insert
  • --lock-tables
  • --quick
  • --set-charset

There are specific scenarios where you might want to disable this option:


# Disabling quick for memory-rich environments with small result sets
mysqldump --skip-quick -u username -p large_database > backup.sql

Cases where disabling might be beneficial:

  • When dealing with very small databases where memory isn't a concern
  • In certain network configurations where single-row fetching causes overhead
  • When you need to minimize the number of round trips to the server

The primary advantage of --quick becomes apparent with large tables:

Option Memory Usage Network Round Trips
--quick Low High
--skip-quick High Low

For most production scenarios, leave --opt (and consequently --quick) enabled. Only consider disabling it when:


# Recommended production dump command
mysqldump --opt -u username -p production_db | gzip > backup_$(date +%F).sql.gz

Key considerations:

  • Always use --opt unless you have specific reasons not to
  • For very large databases, combine with --single-transaction for InnoDB tables
  • Consider pipe compression for network transfers