Florian Weimer <fweimer(at)redhat(dot)com> writes:
> It's still quite surprising that this temporarily needs multiple
> gigabytes of RAM, much more than what's required in in terms of work_mem
> to make this query run quickly.
I doubt there's anything all that interesting there, but if you want
people to investigate this behavior, you'll need to provide a
self-contained test case.
regards, tom lane