Carlos Henrique Reimer <carlos.reimer@opendb.com.br> writes:
> How is the best way to attach a debugger to the SELECT and identify why is
> it exhausting server storage.
In gdb,
call MemoryContextStats(TopMemoryContext)
should produce some useful information on the process's stderr file.
regards, tom lane