"Nestor A. Diaz" <nestor@tiendalinux.com> writes:
> As you can see from above it creates a lots of temp files for the same
> query.
> And finally the query is this:
Could we see what EXPLAIN says about that?
You might try EXPLAIN ANALYZE too, but we're expecting that to run out
of disk space :-(.
I'm speculating wildly here, but I wonder whether it still runs
out of disk space if you remove the COALESCE((SELECT...)) output
expression.
regards, tom lane