rihad <rihad@xxxxxxx> writes: > On 10/25/2019 05:49 PM, Tom Lane wrote: >> You'd need to provide a lot more detail about what that query is doing >> for anyone to be able to guess where the temp file usage is coming from. > I just checked and saw that the function "foo_xml_v2" above returns > table. Is this enough to trigger temporary file usage regardless of > work_mem? No --- that would result in creation of a tuplestore to hold the function result, but it shouldn't spill to disk until it exceeds work_mem ... or at least so I'd expect. Can you extract a self-contained case that creates a small temp file? regards, tom lane