pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: hio: Take number of prior relation extensions into account
Date: Mon, 14 Aug 2023 18:58:35 +0000
Message-ID: <E1qVclu-0007yD-MU@gemulon.postgresql.org> (raw)

hio: Take number of prior relation extensions into account

The new relation extension logic, introduced in 00d1e02be24, could lead to
slowdowns in some scenarios. E.g., when loading narrow rows into a table using
COPY, the caller of RelationGetBufferForTuple() will only request a small
number of pages. Without concurrency, we just extended using pwritev() in that
case. However, if there is *some* concurrency, we switched between extending
by a small number of pages and a larger number of pages, depending on the
number of waiters for the relation extension logic.  However, some
filesystems, XFS in particular, do not perform well when switching between
extending files using fallocate() and pwritev().

To avoid that issue, remember the number of prior relation extensions in
BulkInsertState and extend more aggressively if there were prior relation
extensions. That not just avoids the aforementioned slowdown, but also leads
to noticeable performance gains in other situations, primarily due to
extending more aggressively when there is no concurrency. I should have done
it this way from the get go.

Reported-by: Masahiko Sawada <sawada.mshk@gmail.com>
Author: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAD21AoDvDmUQeJtZrau1ovnT_smN940=Kp6mszNGK3bq9yRN6g@mail.gmail.com
Backpatch: 16-, where the new relation extension code was added

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d37ab378b6e773c278c14b9554a1ea23b355aab9

Modified Files
--------------
src/backend/access/heap/heapam.c |  1 +
src/backend/access/heap/hio.c    | 19 +++++++++++++++++++
src/include/access/hio.h         | 13 ++++++++++---
3 files changed, 30 insertions(+), 3 deletions(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1qVclu-0007yD-MU@gemulon.postgresql.org>
Permalink:  ../E1qVclu-0007yD-MU@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1qVclu-0007yD-MU@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: hio: Take number of prior relation extensions into account
  In-Reply-To: <E1qVclu-0007yD-MU@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