postgresql/src
Andres Freund 82a4edabd2 hio: Take number of prior relation extensions into account
The new relation extension logic, introduced in 00d1e02be2, 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
2023-08-14 11:33:09 -07:00
..
backend hio: Take number of prior relation extensions into account 2023-08-14 11:33:09 -07:00
bin Fix code indentation violations introduced by recent commit 2023-08-11 20:43:34 +09:00
common Avoid memory leak in rmtree() when path cannot be opened 2023-07-31 11:36:44 +09:00
fe_utils Harmonize password reuse in vacuumdb, clusterdb, and reindexdb. 2023-07-28 10:07:44 -07:00
include hio: Take number of prior relation extensions into account 2023-08-14 11:33:09 -07:00
interfaces Translation updates 2023-08-07 12:39:30 +02:00
makefiles Remove --disable-thread-safety and related code. 2023-07-12 08:20:43 +12:00
pl Translation updates 2023-08-07 12:39:30 +02:00
port Use native CRC instructions on 64-bit LoongArch 2023-08-10 11:36:15 +07:00
template Use unnamed POSIX semaphores on Cygwin. 2023-01-06 10:33:28 +13:00
test Change custom wait events to use dynamic shared hash tables 2023-08-14 14:47:27 +09:00
timezone Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
tools pgtest: fix spacing 2023-08-14 14:03:29 -04:00
tutorial Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
.gitignore
DEVELOPERS
Makefile Integrate pg_bsd_indent into our build/test infrastructure. 2023-02-12 12:22:21 -05:00
Makefile.global.in Remove --disable-thread-safety and related code. 2023-07-12 08:20:43 +12:00
Makefile.shlib autoconf: Rely on ar supporting index creation 2022-10-07 11:53:39 -07:00
meson.build Integrate pg_bsd_indent into our build/test infrastructure. 2023-02-12 12:22:21 -05:00
nls-global.mk Fix for make unportability 2022-07-13 09:15:01 +02:00