maintenance_work_mem used by Vacuum

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Sawada Masahiko <sawada(dot)mshk(at)gmail(dot)com>, Teodor Sigaev <teodor(at)sigaev(dot)ru>
Subject: maintenance_work_mem used by Vacuum
Date: 2019-10-06 10:54:49
Message-ID: CAA4eK1LmcD5aPogzwim5Nn58Ki+74a6Edghx4Wd8hAskvHaq5A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

As per docs [1] (see maintenance_work_mem), the maximum amount of memory
used by the Vacuum command must be no more than maintenance_work_mem.
However, during the review/discussion of the "parallel vacuum" patch [2],
we observed that it is not true. Basically, if there is a gin index
defined on a table, then the vacuum on that table can consume up to 2
* maintenance_work_mem memory space. The vacuum can use
maintenance_work_mem memory space to keep track of dead tuples and
another maintenance_work_mem memory space to move tuples from pending pages
into regular GIN structure (see ginInsertCleanup). The behavior related
to Gin index consuming extra maintenance_work_mem memory is introduced by
commit e2c79e14d998cd31f860854bc9210b37b457bb01. It is not clear to me if
this is acceptable behavior and if so, shouldn't we document it?

We wanted to decide how a parallel vacuum should use memory? Can each
worker consume maintenance_work_mem to clean up the gin Index or all
workers should use no more than maintenance_work_mem? We were thinking of
later but before we decide what is the right behavior for parallel vacuum,
I thought it is better to once discuss if the current memory usage model is
right.

[1] - https://www.postgresql.org/docs/devel/runtime-config-resource.html
[2] -
https://www.postgresql.org/message-id/CAD21AoARj%3De%3D6_KOZnaR66jRkDmGaVdLcrt33Ua-zMUugKU3mQ%40mail.gmail.com

--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2019-10-06 10:59:27 Re: [HACKERS] Block level parallel vacuum
Previous Message Pavel Stehule 2019-10-06 08:32:31 Re: dropdb --force