IO:BuffileWrite

This waitevent occurs when PostgreSQL needs to write data to temporary files on disk as part of SQL execution.
This typically happens when operations require more memory than the work_mem parameter allows, causing the system to spill data to disk.
These temporary files are used internally by PostgreSQL for operations that exceed available memory, such as large sorts, hash joins, materialized intermediate results, or batched aggregations.
From SQL tuning perspective, We need to check whether large amount of data is pulled into memory for sort and join operations. Good filtering conditions are important.

For Further reading: [IO:BufFileRead and IO:BufFileWrite]

Common Causes

Temporary files are created when large volume of data is fetched for operations like sorting, joining, or aggregating that exceed the allocated memory (work_mem).