MySQL 8.4 InnoDB temporary table thresholds during large aggregations

Following our migration to MySQL 8.4, an overnight reporting query that normally executed in twelve seconds suddenly spiked to ninety seconds, generating massive disk I/O alerts on our database host.

-- Check the in-memory temporary table engine settings:
SHOW VARIABLES LIKE 'temptable_%';

-- MySQL 8.4 defaults temptable_max_ram to 1GB, but allocates
-- on-disk fallback using TempTable MMAP or InnoDB disk files:
SET GLOBAL temptable_max_ram = 2147483648; -- 2GB
SET GLOBAL temptable_use_mmap = OFF;

The TempTable engine in MySQL 8.4 prefers memory-mapped files once RAM thresholds are crossed. Disabling temptable_use_mmap and allowing the query to spill directly to standard InnoDB temporary tables avoided disk fragmentation and brought the runtime back down to fourteen seconds.