Diagnostic Queries
Symptoms
PostgreSQL could not write to a file (often a temporary or WAL file) because the device is full. It raises SQLSTATE 53100 (disk_full).
- Common with large sorts/hash joins writing temp files.
- Also seen when the WAL/pg_wal directory volume fills.
- The named file indicates whether it is temp, WAL, or relation data.
What the server log shows
ERROR: could not write to file "base/pgsql_tmp/pgsql_tmp12345.0": No space left on device
Why PostgreSQL raises this — what the manual says
Section 19.4.2 Disk (temp_file_limit):
“Specifies the maximum amount of disk space that a process can use for temporary files, such as sort and hash temporary files, or the storage file for a held cursor.”
Operations that exceed memory spill to temporary files; WAL and relations also write to disk. When the volume is full, the OS write fails and PostgreSQL reports 53100, cancelling the operation.
Common causes
- Huge sorts/hash joins spilling large temp files.
- The temp tablespace volume running out of space.
- WAL accumulation filling pg_wal.
How to fix it
- Cap per-process temp usage with
temp_file_limit. - Reduce data scanned/sorted; add indexes or paginate.
- Move temp files to a larger tablespace, or expand the volume.
Related & next steps
Reference: PostgreSQL 18 Section 19.4 “Resource Consumption”.
Thanks — noted. This helps keep the database accurate.