pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Lance Luvaul <lance.luvaul@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Full list of operations that constitute a "maintenance" operation?
Date: Fri, 09 Nov 2018 13:35:07 +0000
Message-ID: <87muqixvh0.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <CABJWDxSibrFwK11duJPxFcVs6jdDg8gqAm9S0jYdHK_bv9DPog@mail.gmail.com>
References: <CABJWDxSibrFwK11duJPxFcVs6jdDg8gqAm9S0jYdHK_bv9DPog@mail.gmail.com>

>>>>> "Lance" == Lance Luvaul <lance.luvaul@gmail.com> writes:

 Lance> Hi all, I've read on the Postgres documentation for
 Lance> 'maintenance_work_mem' that VACUUM, CREATE INDEX, and ALTER
 Lance> TABLE ADD FOREIGN KEY are considered maintenance operations, but
 Lance> are there others? For example I use ALTER TABLE ADD COLUMN and
 Lance> ALTER TABLE SET LOGGED in my scripts... are they maintenance
 Lance> operations that would cause a maintenance_work_mem-sized chunk
 Lance> of memory (or more than 1 such chunk) to be allocated?

There are essentially two classes of operations that use
maintenance_work_mem:

1. Specific operations: non-full VACUUM (for the deleted tid list),
CLUSTER (for sorting the table content), ALTER ... ADD FOREIGN KEY (for
the validation query, which might want to use sorts or a hashjoin).
(It's not impossible, though it should be rare, for an FK validation to
use two chunks of maintenance_work_mem - with the right table sizes and
data types, the validation query could plan as a merge anti-join with
explicit sorts on both sides.)

2. Anything that (re)builds an index for any reason. This includes a
large set of operations: CREATE INDEX and REINDEX are obvious, likewise
VACUUM FULL and CLUSTER, but also any form of ALTER TABLE that rewrites
the heap (which _includes_ SET LOGGED, but does not include adding a
column with no default, or in pg11+ adding a column with a default). It
also includes non-concurrent refresh of a materialized view. (TRUNCATE
also technically rewrites the table heap, but since the new heap is
empty, memory consumption during reindex is not an issue.) ALTER TABLE
to add a unique, primary key or exclusion constraint also creates an
index to implement the constraint with (unless USING INDEX was used to
adopt an existing index) so that counts too.

-- 
Andrew (irc:RhodiumToad)




view thread (3+ messages)

Message-ID: <87muqixvh0.fsf@news-spur.riddles.org.uk>
Permalink:  ../87muqixvh0.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87muqixvh0.fsf@news-spur.riddles.org.uk

 · 

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-general@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, lance.luvaul@gmail.com
  Subject: Re: Full list of operations that constitute a "maintenance" operation?
  In-Reply-To: <87muqixvh0.fsf@news-spur.riddles.org.uk>
  References: <CABJWDxSibrFwK11duJPxFcVs6jdDg8gqAm9S0jYdHK_bv9DPog@mail.gmail.com> <87muqixvh0.fsf@news-spur.riddles.org.uk>

* 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