Carlos Henrique Reimer <carlos(dot)reimer(at)opendb(dot)com(dot)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