pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid some overhead with open and close of catalog indexes
Date: Wed, 16 Nov 2022 01:50:53 +0000
Message-ID: <E1ov7Zk-000O8a-9W@gemulon.postgresql.org> (raw)

Avoid some overhead with open and close of catalog indexes

This commit improves two code paths to open and close indexes a
minimum amount of times when doing a series of catalog updates or
inserts.  CatalogTupleInsert() is costly when using it for multiple
inserts or updates compared to CatalogTupleInsertWithInfo(), as it would
need to open and close the indexes of the catalog worked each time an
operation is done.

This commit updates the following places:
- REINDEX CONCURRENTLY when copying statistics from one index relation
to the other.  Multi-INSERTs are avoided here, as this would begin to
show benefits only for indexes with multiple expressions, for example,
which may not be the most common pattern.  This change is noticeable in
profiles with indexes having many expressions, for example, and it would
improve any callers of CopyStatistics().
- Update of statistics on ANALYZE, that mixes inserts and updates.
In each case, the catalog indexes are opened only if at least one
insertion and/or update is required, to minimize the cost of the
operation.  Like the previous coding, no indexes are opened as long as
at least one insert or update of pg_statistic has happened.

Author: Ranier Vilela
Reviewed-by: Kyotaro Horiguchi, Michael Paquier
Discussion: https://postgr.es/m/CAEudQAqh0F9y6Di_Wc8xW4zkWm_5SDd-nRfVsCn=h0Nm1C_mrg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/09a72188cd5cdd179dc814c6729f8a3785b23c36

Modified Files
--------------
src/backend/catalog/heap.c     | 10 +++++++++-
src/backend/commands/analyze.c | 11 +++++++++--
2 files changed, 18 insertions(+), 3 deletions(-)



Message-ID: <E1ov7Zk-000O8a-9W@gemulon.postgresql.org>
Permalink:  ../E1ov7Zk-000O8a-9W@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ov7Zk-000O8a-9W@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: michael@paquier.xyz
  Subject: Re: pgsql: Avoid some overhead with open and close of catalog indexes
  In-Reply-To: <E1ov7Zk-000O8a-9W@gemulon.postgresql.org>
  References: <E1ov7Zk-000O8a-9W@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