Hi Anton,
I can reproduce the high memory consumption with your queries.
Looking at the patch, I see that you changed the lifetime of the
temporary context from per-tuple to per-index-scan. It is not obvious
that this change is correct. Could you explain, what memory context are
involved in the scan, and what their lifetimes are, before and after
your changes? What are these memory allocations that are causing the
high consumption, and what code makes them? This will make it easier to
understand your changes.
>
https://www.postgresql.org/message-id/flat/CAPqRbE5vTGWCGrOc91Bmu-0o7CwsU0UCnAshOtpDR8cSpSjy0g%40mail.gmail.com#CAPqRbE5vTGWCGrOc91Bmu-0o7CwsU0UCnAshOtpDR8cSpSjy0g@mail.gmail.com
Also, this link doesn't open for me.
--
Alexander Kuzmenkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company