Bug #118444 Improve upgrade time of MySQL with a large number of tables (1 million table)
Submitted: 13 Jun 8:06 Modified: 13 Jun 10:18
Reporter: Simon Mudd (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Data Dictionary Severity:S4 (Feature request)
Version:8.0 / 8.4 / 9.X OS:Any
Assigned to: CPU Architecture:Any

[13 Jun 8:06] Simon Mudd
Description:
This is a public report for a feature request to improve behaviour of an issue already known to Oracle.  Reported in public for others to be aware of.

Upgrading a server with a large number of tables can take a long time. With ~1 million tables the MySQL upgrade can take about 45 minutes on reasonable hardware.
The process is CPU bound to a single CPU and I/O is low.

A normal server restart time of the same server is about 25 seconds.

Related to similar reports which complain about start up times:
- bug#115988
- bug#116715

I don't see a specific issue with startup times but my system seems to be larger: 128 GB RAM / nvme storage / 24+ cores.

However, the upgrade time is significantly longer and much more of a concern.

How to repeat:
Create a setup with ~1 million tables. Upgrade from 8.0.41 -> 8.0.42.
- similar issues seen with 8.0 -> 8.4 upgrades
- similar issues seen with 8.4 upgrades

Partial logging for a 8.0.39 -> 8.0.42 upgrade:

...
2025-06-13T06:34:37.976685Z 1 [Note] [MY-012976] [InnoDB] 8.0.42 started; log sequence number 65655721124520
2025-06-13T06:34:37.978598Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-06-13T06:34:37.990905Z 1 [Note] [MY-013327] [Server] MySQL server upgrading from version '80039' to '80042'.
2025-06-13T06:34:38.269264Z 1 [Note] [MY-012357] [InnoDB] Reading DD tablespace files
2025-06-13T06:34:40.242438Z 1 [Note] [MY-012356] [InnoDB] Scanned 61410 tablespaces. Validated 61410.
<<< large pause here >>>
2025-06-13T07:17:21.927718Z 1 [Note] [MY-010006] [Server] Using data dictionary with version '80023'.
2025-06-13T07:17:23.172925Z 0 [Note] [MY-011332] [Server] Plugin mysqlx reported: 'IPv6 is available'
2025-06-13T07:17:23.173099Z 0 [Note] [MY-011323] [Server] Plugin mysqlx reported: 'X Plugin ready for connections. bind-address: '::' port: 33060'
2025-06-13T07:17:23.173122Z 0 [Note] [MY-011323] [Server] Plugin mysqlx reported: 'X Plugin ready for connections. socket: '/var/run/mysqld/mysqlx.sock''
2025-06-13T07:17:23.202299Z 3 [Note] [MY-014066] [Server] Upgrading performance schema from version 80033 to 80040.
2025-06-13T07:17:24.482510Z 4 [System] [MY-013381] [Server] Server upgrade from '80039' to '80042' started.
2025-06-13T07:17:24.483474Z 4 [Note] [MY-013386] [Server] Running queries to upgrade MySQL server.
2025-06-13T07:17:41.214594Z 4 [Note] [MY-013387] [Server] Upgrading system table data.
2025-06-13T07:17:41.982447Z 4 [Note] [MY-013385] [Server] Upgrading the sys schema.
2025-06-13T07:17:42.663822Z 4 [Note] [MY-013400] [Server] Upgrade of help tables started.
2025-06-13T07:17:42.798392Z 4 [Note] [MY-013400] [Server] Upgrade of help tables completed.
2025-06-13T07:17:42.798496Z 4 [Note] [MY-013394] [Server] Checking 'mysql' schema.
2025-06-13T07:17:42.860721Z 4 [Note] [MY-013394] [Server] Checking 'sys' schema.
2025-06-13T07:17:42.881152Z 4 [System] [MY-013381] [Server] Server upgrade from '80039' to '80042' completed.
...

This system has 1527950 tables and 61410 tablespaces, and the dataset size was ~1 TB.

Suggested fix:
Improve startup time to something which is more "Reasonable".

While I understand that it is unusual to have a large number of tables, these days servers get larger so avoiding bottlenecks would be good.  The upgrade process being CPU bound to a single CPU also stands out.
[13 Jun 10:18] MySQL Verification Team
Hello Simon,

Thank you for the reasonable feature request!

regards,
Umesh