Starting at version MySQL5.6+ by default innodb_file_per_table is enabled and all data is stored in separate tablespaces. It provides some advantages.
Impact of innodb_file_per_table Option On Crash Recovery Time appeared first on MariaDB.org
Starting at version MySQL5.6+ by default innodb_file_per_table is enabled and all data is stored in separate tablespaces. It provides some advantages.

I will highlight some of them:
There are disadvantages described on MySQL man page but I found another one that is not mentioned: if you have a huge number of tables, the crash recovery process may take a lot of time. During crash recovery the MySQL daemon scans .ibd files:
2019-07-16 21:00:04 6766 [Note] InnoDB: Starting crash recovery.
2019-07-16 21:00:04 6766 [Note] InnoDB: Reading tablespace information from the .ibd files...
# Started at Jul 16 23:46:52:
Version: '5.6.39-83.1-log' socket: ......During startup time I checked MySQL behavior and found that MySQL opens files one by one. In my test case it was 1400000+ tables and it took 02:46:48 just to scan ibd files.
To prevent such a long downtime we decided to move all the tables to shared tablespaces.
Solution – moving tables to shared tablespacesYou can use this script:
# Get table list that stored in own tablespace (SPACE>0)
mysql -NB information_schema -e "select NAME from INNODB_SYS_TABLES WHERE name not like 'SYS_%' AND name not like 'mysql/%' AND SPACE > 0" | split -l 30000 - tables;
# Generate SQL script
for file in `ls tables*`;
do
perl -e '$curdb=""; while(<STDIN>) {chomp; ($db,$table) = split(///); if ($curdb ne $db ) { print "USE $db;n"; $curdb=$db; } print "ALTER TABLE $table engine=innodb;n"; }' < $file > $file.SQL;
done
# Apply files $file.SQL ( you can use parallel execution ) :
cat<<EOF>convert.sh
file=$1
mysql < ${file}
EOF
# Do not forget to fix my.cnf
mysql -e "set global innodb_file_per_table = 0"
chmod +x convert.sh
# run 10 parallel threads
ls tables*.SQL | xargs -n1 -P10 ./convert.shWhat the script does:
After changing file_per_table to 0 and moving the InnoDB tables:
2019-07-17 22:16:47 976 [Note] InnoDB: Reading tablespace information from the .ibd files...
2019-07-17 22:25:45 976 [Note] mysqld: ready for connections.Using the default value of innodb_file_per_table (ON) is not always a good choice. In my test case: 4000+ databases, 1400000+ tables. I reduced recovery time from 02:46:48 to 00:08:58 seconds. That’s 18 times less! Remember, there is no “golden my.cnf config”, and each case is special. Optimize MySQL configuration according to your needs.
–
The content in this blog is provided in good faith by members of the open source community. The content is not edited or tested by Percona, and views expressed are the authors’ own. When using the advice from this or any other online resource, please test ideas before applying them to your production systems, and **always **secure a working back up.
Cartoon source https://imgur.com/ ∎

For the last 10 years, Timur has worked in various telco companies. He has hands-on experience in databases, system and network engineering. Currently Timur works as a Senior DBA for Five9, Inc., the leading provider of cloud contact center software. He lives in California, US with wife and daughter.
| # | Наименование новости | Тональность | Информативность | Дата публикации |
|---|---|---|---|---|
| 1 | Shrinking the InnoDB system tablespace | 0 | 7.28 | 17-06-2024 |
| 2 | Understanding InnoDB Tablespace Duplicate Check (MySQL Startup with Many Tables) | 0 | 4.76 | 19-11-2024 |
| 3 | InnoDB Buffer Pool Tuning: From Rule-of-Thumb to Real Signals | 0 | 10.35 | 02-04-2026 |
| 4 | MariaDB has broken the concept of dynamically configurable buffer pools! | 0 | 10.18 | 09-02-2026 |
| 5 | InnoDB Redo Log Sizing: Stop Guessing, Start Measuring | 0 | 5.82 | 02-05-2026 |
| 6 | Do not uselessly grant CREATE and ALTER TABLE | 0 | 9.11 | 20-06-2026 |
| 7 | InnoDB Tablespace Duplicate Check Threads (and EBS Volumes for MySQL Startup with Many Tables) | 0 | 7.41 | 03-12-2024 |
| 8 | Cross-site Disaster Recovery with Percona Operator for MySQL | 0 | 6.1 | 06-07-2026 |
| 9 | MariaDB Innovation: InnoDB-Based Binary Log | 0 | 17.58 | 17-03-2026 |