A MySQL query slows down, temporary storage grows, and the disk alert fires.
Fastest fix: identify whether the growth is TempTable memory spillover, a temporary-directory file, or an InnoDB temporary tablespace; then correlate it with the query plan and workload before changing limits or touching files.
This guide is for DBAs handling MySQL 8.4 temporary-table writes, disk alerts, or slow queries.
Backend engineers can use the query and execution-plan checks to trace the statements involved.
Technical leads can use the evidence to decide whether memory, NVMe layout, or capacity needs review.
Last updated November 16, 2026; MySQL behavior and release details checked against the MySQL 8.4 Reference Manual and official release notes.
Diagnose the symptom before assigning a cause
A slow query, rising disk use, more disk temporary tables, and a failed write are related signals, but they are not interchangeable. Record what changed, when it changed, and which filesystem or database instance is affected. That baseline helps distinguish a single expensive statement from a concurrency problem or a file that remains allocated after temporary work finishes.
| What you observe | What it may indicate | First check |
|---|---|---|
| A query slows while disk activity rises | A statement may be sorting, grouping, or materializing an intermediate result | Compare the query plan and execution time with the incident window |
| Temporary-directory use grows | Temporary files or memory-mapped temporary data may be involved | Check the configured temporary directory and filesystem |
| The data directory grows or a temporary tablespace file remains large | InnoDB temporary-table space may be involved, or allocated space may remain after use | Inspect the file and MySQL temporary-tablespace state |
| Disk errors appear | The filesystem may be out of usable space, or a write may have failed | Identify the exact mount point and the MySQL error before cleanup |
MySQL 8.4.13 was released on October 20, 2026, according to its official release notes. The release date does not mean that the temporary-table mechanism is new in this patch. The relevant behavior is documented in the MySQL 8.4 manual.
First step: capture the time and location
At the time of an alert, record the host, affected filesystem, MySQL error-log entries, query latency, concurrent workload, and the approximate start and end of the increase. Avoid relying on a later snapshot alone: a temporary file may already have disappeared, while an InnoDB temporary tablespace can retain allocated space.
Check the configured locations rather than assuming temporary files sit beside database data. MySQL documents tmpdir as the location used for temporary files; confirm the active setting and the filesystem behind it using the temporary-file documentation.
How can you tell whether a MySQL 8.4 internal temporary table used memory or disk?
Do not infer the storage path from query latency or a single global counter. Compare the relevant server variables, temporary-table status counters, Performance Schema observations, and filesystem changes during the same workload window. MySQL documents multiple internal temporary-table storage paths, so the evidence must be read together.
Separate the temporary storage paths
MySQL can use the TempTable storage engine for internal temporary tables. Depending on memory limits and configuration, temporary data can involve in-memory storage, memory-mapped files, or an on-disk InnoDB temporary table. A memory-mapped file may not behave like a plainly visible, long-lived file in a directory listing, so an empty-looking directory does not by itself rule out temporary storage use.
| Storage path | What to verify | What the observation does not prove |
|---|---|---|
| TempTable in memory | TempTable-related memory observations and active workload | That the workload has no disk temporary data |
| Memory-mapped temporary files | temptable_max_mmap, tmpdir, and filesystem activity |
That Created_tmp_disk_tables captures every spill to disk |
| InnoDB temporary tablespace | The temporary tablespace state and file allocation | That a large allocated file is still actively growing |
| Other temporary files | The configured tmpdir and MySQL’s file activity |
That every file in the directory belongs to the same query |
The MySQL manual explains the internal temporary-table storage and monitoring behavior. For the InnoDB path, check the manual’s guidance on temporary tablespace lifecycle and inspection.
A practical inventory starts with the configured values and status counters:
SHOW VARIABLES LIKE 'tmpdir';
SHOW VARIABLES LIKE 'tmp_table_size';
SHOW VARIABLES LIKE 'temptable%';
SHOW GLOBAL STATUS LIKE 'Created_tmp%';
Capture these observations at a consistent interval and compare them with disk usage. Global status values are not a per-query attribution mechanism; take before-and-after samples and account for the server’s uptime and concurrent workload. Performance Schema can add memory-level evidence, but instrumentation availability and interpretation matter. Consult the memory summary table documentation rather than assuming every memory event is enabled or visible.
Important:
Created_tmp_disk_tablesis not a complete count of every temporary disk allocation. In particular, it does not account for every memory-mapped temporary file. A flat counter does not prove that temporary storage is not contributing to disk use.
Find the statement behind the growth
Temporary-table activity can be triggered by sorting, aggregation, derived tables, common table expressions, or materialization. The SQL text alone may not reveal whether a particular execution spills. Compare representative statements with the actual workload and inspect their plans.
Start with the slow query log if it is available and configured to capture the relevant statements. Its documented fields and logging scope help establish what the log can and cannot show. Then use Performance Schema statement history or digest summaries to find recurring statements around the alert window. A global increase in temporary-table counters identifies activity, not the responsible digest.
For a candidate statement, run EXPLAIN with the same relevant schema and query shape. Check for sort operations, materialization, derived-table processing, and access paths that scan or produce more rows than expected. MySQL’s EXPLAIN reference describes the plan output; the plan is evidence about execution strategy, not a substitute for observing the query under representative data and concurrency.
What should you do when a query slows after temporary data spills to disk?
First identify the statement and verify that its plan or observed execution accounts for the storage growth. Then test a targeted change—such as an index or SQL rewrite—against the same representative query and workload. Do not raise global memory limits just because a query became slower; another statement may be consuming the same resources.
A useful comparison is the same query run with representative data under normal concurrency, then under the conditions associated with the alert. Record execution time, plan changes, relevant temporary-table counters, and filesystem use. If the query performs acceptably in isolation but degrades at peak load, investigate concurrent demand before attributing the problem to that statement alone.
Tune limits only after checking their relationship
Several MySQL 8.4 settings affect temporary-table behavior, but they govern different boundaries. Increasing one per-table limit does not create additional physical memory or guarantee that a workload will stop using disk. Review the system-variable reference and compare settings with observed memory pressure and concurrency.
| Setting or signal | Role in the investigation | Common misreading |
|---|---|---|
tmp_table_size |
A per-table limit relevant to in-memory internal temporary tables | Raising it is not the same as expanding total server memory |
temptable_max_ram |
A limit on TempTable memory use | A global limit is not a safe allowance for every query at once |
temptable_max_mmap |
A limit related to memory-mapped temporary files | A higher value does not eliminate the need to monitor the backing filesystem |
Created_tmp_disk_tables |
A status counter for disk-based internal temporary tables | It does not count every kind of temporary disk allocation |
| Performance Schema memory observations | Can show instrumented memory use | Missing or disabled instrumentation can leave gaps |
Can increasing tmp_table_size solve a full disk?
Not by itself. It changes a per-table threshold, while TempTable memory and memory-mapped storage have separate controls and the machine has finite resources. A larger threshold can shift where a workload consumes resources; it does not prove that the workload is safe at peak concurrency. Confirm which storage path is growing and model the competing memory demand before changing a limit.
Before editing a setting, save the existing value and define what evidence would count as success or failure. Make one controlled change at a time, observe the same workload, and keep a rollback path. If memory pressure rises, the disk remains full, or query behavior becomes less predictable, revert and investigate the query plan or concurrency instead.
Check allocated files before taking action
A temporary tablespace file that remains large does not automatically mean it is still growing or that it can be removed. Distinguish active use, ongoing allocation, and space that remains allocated for reuse. Inspect MySQL’s state and the filesystem before deciding whether maintenance is appropriate. Follow the documented InnoDB temporary-tablespace inspection guidance.
Never delete a file that MySQL may still be using. Do not treat a server restart as a harmless universal cleanup: it affects service availability and may not address the query or workload that caused the growth. If the filesystem is close to exhaustion, first determine which files are consuming space and whether MySQL is actively writing. Plan any disruptive maintenance with an approved recovery and rollback procedure.
A safe investigation sequence is:
- [ ] Record the affected filesystem, MySQL instance, alert time, and relevant error-log entries.
- [ ] Check
tmpdir, the data-directory mount, and the actual location of the growing files. - [ ] Capture temporary-table variables and status counters at comparable times.
- [ ] Review Performance Schema memory observations and note any instrumentation gaps.
- [ ] Find candidate statements in the slow query log or Performance Schema.
- [ ] Compare their
EXPLAINplans with the observed workload and concurrency. - [ ] Change one query or setting at a time, then repeat the same measurement.
- [ ] Confirm that the temporary storage is stable and that disk headroom is adequate before closing the incident.
- [ ] Verify that database backups are stored off-host and that restore procedures have been tested.
Turn the evidence into a resource decision
After a query or configuration change, repeat the workload that triggered the alert. Check whether the plan changed as intended, whether temporary-space indicators moved in the expected direction, and whether filesystem use stayed stable under similar concurrency. If the issue disappears only when the workload is lighter, the remaining problem may be capacity planning rather than a single faulty query.
Translate those observations into requirements: peak memory demand, space needed for database files and temporary work, expected concurrent queries, and room for operational maintenance. NVMe capacity alone does not establish that a workload will fit; layout and free-space reserves matter. If separating data, logs, or temporary files is under consideration, first confirm which paths MySQL actually uses and whether the intended filesystems have enough capacity.
Dedicated hardware does not protect a database from data loss. Use a suitable software RAID or replication plan where appropriate, keep backups off the database host, and rehearse recovery. A server with spare memory or storage is not a replacement for backups or restore testing.
Shared VPS or public-cloud instances may suit workloads that need short-lived elasticity or minimal operational responsibility. But resource contention, CPU overcommit, usage-based storage or I/O charges, and limited control over disk layout can make sustained database workloads harder to predict. If the evidence points to a need for dedicated compute and stable long-term storage planning, compare the actual available memory, NVMe, operating systems, and access method in IronStp’s current server listings before deciding whether to migrate. Review how the service works as part of that evaluation; do not choose a new server based on an unverified threshold or a single disk alert.
Give MySQL Workloads Dedicated Room to Grow
Configure an IronStp AMD EPYC 7543P server with 32 cores and 64 threads for your database workloads.
