This was performed on Ubuntu 14.04 with a fresh install of PostgreSQL 9.3.14 directly from the official Postgres apt repo. It only works if the query planner chooses the attached plan (with HashAggregate).
Create and populate a new database:
psql -U postgres -c "create database test;"
psql -U postgres test < populate.sql
Open a connection to the database and execute query.sql
. The Postgres worker memory usage will rise approximately 50MB and won't be released until the connection is closed.
So as far as I know, it is the query planner that triggers the memory leak? This is quite interesting, that only this planner leads to the leak. I read the mails and it stops here: https://www.postgresql.org/message-id/257030f3-b9ed-1ad7-ebef-189c88608e41%40hogranch.com. Is there any further details about this issue?