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.
Why this is a memory leak? Is it possible that the server still maintains runtime objects/resources? As I know, a
leak
is something that is still alive after you stop the process/program that creates it. Since you said it is gone after closing connection, it shouldn't be a leak.