pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Davis <jdavis@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Create memory context for HashAgg with a reasonable maxBlockSize
Date: Wed, 08 Apr 2020 04:29:21 +0000
Message-ID: <E1jM2L3-000497-Kc@gemulon.postgresql.org> (raw)

Create memory context for HashAgg with a reasonable maxBlockSize.

If the memory context's maxBlockSize is too big, a single block
allocation can suddenly exceed work_mem. For Hash Aggregation, this
can mean spilling to disk too early or reporting a confusing memory
usage number for EXPLAN ANALYZE.

Introduce CreateWorkExprContext(), which is like CreateExprContext(),
except that it creates the AllocSet with a maxBlockSize that is
reasonable in proportion to work_mem.

Right now, CreateWorkExprContext() is only used by Hash Aggregation,
but it may be generally useful in the future.

Discussion: https://postgr.es/m/412a3fbf306f84d8d78c4009e11791867e62b87c.camel@j-davis.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/50a38f65177ea7858bc97f71ba0757ba04c1c167

Modified Files
--------------
src/backend/executor/execUtils.c | 71 +++++++++++++++++++++++++++++++---------
src/backend/executor/nodeAgg.c   |  5 +--
src/include/executor/executor.h  |  1 +
3 files changed, 58 insertions(+), 19 deletions(-)



Message-ID: <E1jM2L3-000497-Kc@gemulon.postgresql.org>
Permalink:  ../E1jM2L3-000497-Kc@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1jM2L3-000497-Kc@gemulon.postgresql.org

 · 

reply

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-committers@postgresql.org
  Cc: jdavis@postgresql.org
  Subject: Re: pgsql: Create memory context for HashAgg with a reasonable maxBlockSize
  In-Reply-To: <E1jM2L3-000497-Kc@gemulon.postgresql.org>
  References: <E1jM2L3-000497-Kc@gemulon.postgresql.org>

* 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