From: Alexey Bashtanov <bashtanov@imap.cc>
To: tao tony <tonytao0505@outlook.com>
To: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: partition table query allocate much memory
Date: Thu, 24 May 2018 09:52:50 +0100
Message-ID: <fdb54e28-e2ce-e9d2-8a85-078b315ea6ae@imap.cc> (raw)
In-Reply-To: <BY1PR13MB0022DA3DE3C8F694A41E950CAA990@BY1PR13MB0022.namprd13.prod.outlook.com>
References: <BY1PR13MB0022DA3DE3C8F694A41E950CAA990@BY1PR13MB0022.namprd13.prod.outlook.com>
Hello Tao,
> I'm not sure it was a bug and I also cloud not explain why it
> allocated so much memory.Dosn't each sub partition table allocated the
> size of work_mem memory and not free it?
It can, and it did it for hashed subPlan at least in PG 9.4, see
https://www.slideshare.net/AlexeyBashtanov/postgresql-and-ram-usage/41
Generally, work_mem is per operation, not per query -- that's not a bug
> When work_mem=1GB or more,the query plan is a
> HashAggregate.otherwise it was Unique and running on parallel mode.
>
I would appreciate if you could send full plans with ANALYZE.
I suspect it's hashed subPlan hashing goodsh.gid separately for each
partition, but maybe something else.
NOT IN is generally tricky, both semantically and for planning,
rewriting it into NOT EXISTS or LEFT JOIN may change the plan dramatically.
Best,
Alexey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: bashtanov@imap.cc, tonytao0505@outlook.com
Subject: Re: partition table query allocate much memory
In-Reply-To: <fdb54e28-e2ce-e9d2-8a85-078b315ea6ae@imap.cc>
References: <BY1PR13MB0022DA3DE3C8F694A41E950CAA990@BY1PR13MB0022.namprd13.prod.outlook.com> <fdb54e28-e2ce-e9d2-8a85-078b315ea6ae@imap.cc>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox