patternsqlMinor
Why MySQL Database is Bigger After Dump/Import?
Viewed 0 times
afterdumpwhybiggerdatabasemysqlimport
Problem
I have 2 VPS and plan to migrate the DB from first to second. The original DB is taking around 15GB of storage and I manage to dump out a 7GB SQL. However, when I imported the SQL to second VPS, it takes up 2x of storage becoming 32GB.
My questions are:
Below are some further detail:
14858M /var/lib/mysql
14483M /var/lib/mysql/ibdata1
365M /var/lib/mysql/wordpress
31558M /var/lib/mysql
31306M /var/lib/mysql/wordpress
337M /var/lib/mysql/wordpress/wp_wfLeechers.ibd
101M /var/lib/mysql/wordpress/wp_1059_posts.ibd
My questions are:
- What might cause my DB from 15GB to become 32GB by just dump+import?
- How can I avoid this?
Below are some further detail:
- Both VPS are not exactly same and so do the MySQL version. The source DB is version 5.5.47. The receiving DB is version 5.7.13.
- The receiving DB is newly install and empty.
- The command I used to dump out SQL is:
mysqldump -u -p --all-databases --add-drop-database --max_allowed_packet=16777216 --single-transaction > full_dump.sql. The reason I am setting max_allowed_packet is to have the same value compare to receiving DB
- Not sure if this is relevant. If I do not specify
single-transactionin my mysqldump command, it will errormysqldump: Got error: 2006: MySQL server has gone away when using LOCK TABLES
- The source DB storage distribution is different from the receiving DB:
14858M /var/lib/mysql
14483M /var/lib/mysql/ibdata1
365M /var/lib/mysql/wordpress
- This is the receiving DB storage distribution:
31558M /var/lib/mysql
31306M /var/lib/mysql/wordpress
337M /var/lib/mysql/wordpress/wp_wfLeechers.ibd
101M /var/lib/mysql/wordpress/wp_1059_posts.ibd
- I've tried to run table optimisation, but no impact
Solution
The first thing that caught my eye was the versions of MySQL you are using.
You said
These two versions of MySQL use different default values for innodb_file_format
MySQL 5.7 has new ways of storing InnoDB as mentioned in the Documentation. Please note:
The Barracuda file format is required to use Compressed or Dynamic row formats and associated features such as compression, off-page storage for large variable-length columns, and large index key prefixes (see innodb_large_prefix). This restriction does not apply to tables stored in general tablespaces.
If your data has large variable-length columns, the result of reloading could be the storage of data and index info outside of your BTree Indexes and extra splitting of pages. See DYNAMIC and COMPRESSED Row Formats for more details on this. Many of the new InnoDB file format features are deprecated in MySQL 5.7 and will eventually disappear in future releases.
SUGGESTION #1
Even though deprecated, you could set innodb_file_format to Antelope on the MySQL 5.7 server, restart MySQL, and reload the mysqldump.
SUGGESTION #2
Use MySQL 5.5/5.6 as the Master instead of MySQL 5.7. Restart MySQL on the Master, and reload mysqldump into the Master.
SUGGESTION #3
Run
GIVE IT A TRY !!!
You said
- The source DB is version 5.5.47
- The receiving DB is version 5.7.13
These two versions of MySQL use different default values for innodb_file_format
- MySQL 5.5 has Antelope as the default
- MySQL 5.7 has Barracuda as the default
MySQL 5.7 has new ways of storing InnoDB as mentioned in the Documentation. Please note:
The Barracuda file format is required to use Compressed or Dynamic row formats and associated features such as compression, off-page storage for large variable-length columns, and large index key prefixes (see innodb_large_prefix). This restriction does not apply to tables stored in general tablespaces.
If your data has large variable-length columns, the result of reloading could be the storage of data and index info outside of your BTree Indexes and extra splitting of pages. See DYNAMIC and COMPRESSED Row Formats for more details on this. Many of the new InnoDB file format features are deprecated in MySQL 5.7 and will eventually disappear in future releases.
SUGGESTION #1
Even though deprecated, you could set innodb_file_format to Antelope on the MySQL 5.7 server, restart MySQL, and reload the mysqldump.
SUGGESTION #2
Use MySQL 5.5/5.6 as the Master instead of MySQL 5.7. Restart MySQL on the Master, and reload mysqldump into the Master.
SUGGESTION #3
Run
ALTER TABLE innodbtable ROW_FORMAT=COMPRESSED; on all the MySQL 5.7 InnoDB tables.GIVE IT A TRY !!!
Context
StackExchange Database Administrators Q#149200, answer score: 2
Revisions (0)
No revisions yet.