postgresql/src/include
Tomas Vondra 8c4040edf4 Allocate hash join files in a separate memory context
Should a hash join exceed memory limit, the hashtable is split up into
multiple batches. The number of batches is doubled each time a given
batch is determined not to fit in memory. Each batch file is allocated
with a block-sized buffer for buffering tuples and parallel hash join
has additional sharedtuplestore accessor buffers.

In some pathological cases requiring a lot of batches, often with skewed
data, bad stats, or very large datasets, users can run out-of-memory
solely from the memory overhead of all the batch files' buffers.

Batch files were allocated in the ExecutorState memory context, making
it very hard to identify when this batch explosion was the source of an
OOM. This commit allocates the batch files in a dedicated memory
context, making it easier to identify the cause of an OOM and work to
avoid it.

Based on initial draft by Tomas Vondra, with significant reworks and
improvements by Jehan-Guillaume de Rorthais.

Author: Jehan-Guillaume de Rorthais <jgdr@dalibo.com>
Author: Tomas Vondra <tomas.vondra@enterprisedb.com>
Reviewed-by:  Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/20190421114618.z3mpgmimc3rmubi4@development
Discussion: https://postgr.es/m/20230504193006.1b5b9622%40karst#273020ff4061fc7a2fbb1ba96b281f17
2023-05-19 17:17:58 +02:00
..
access Fix handling of empty ranges and NULLs in BRIN 2023-05-19 01:29:44 +02:00
archive Redesign archive modules 2023-02-17 14:26:42 +09:00
backup Fix some typos and some incorrectly duplicated words 2023-04-18 14:03:49 +12:00
bootstrap Update copyright for 2023 2023-01-02 15:00:37 -05:00
catalog Add writeback to pg_stat_io 2023-05-17 11:18:35 -07:00
commands Revert "Catalog NOT NULL constraints" and fallout 2023-04-12 19:29:21 +02:00
common Remove stray mid-sentence tabs in comments 2023-05-19 16:13:16 +02:00
datatype Code review for commit 05a7be935. 2023-01-26 12:51:00 -05:00
executor Allocate hash join files in a separate memory context 2023-05-19 17:17:58 +02:00
fe_utils Update copyright for 2023 2023-01-02 15:00:37 -05:00
foreign Update copyright for 2023 2023-01-02 15:00:37 -05:00
jit Update copyright for 2023 2023-01-02 15:00:37 -05:00
lib Fix various typos in code and tests 2023-02-09 14:43:53 +09:00
libpq De-Revert "Add support for Kerberos credential delegation" 2023-04-13 08:55:07 -04:00
mb Update copyright for 2023 2023-01-02 15:00:37 -05:00
nodes Revert "Add USER SET parameter values for pg_db_role_setting" 2023-05-17 20:28:57 +03:00
optimizer Tweak API of new function clause_is_computable_at(). 2023-05-18 10:39:16 -04:00
parser Fix crashes with CREATE SCHEMA AUTHORIZATION and schema elements 2023-04-28 19:29:12 +09:00
partitioning Revert "Move PartitionPruneInfo out of plan nodes into PlannedStmt" 2023-05-04 12:09:59 +02:00
pch Update copyright for 2023 2023-01-02 15:00:37 -05:00
port Remove stray mid-sentence tabs in comments 2023-05-19 16:13:16 +02:00
portability instr_time: Represent time as an int64 on all platforms 2023-01-20 21:16:47 -08:00
postmaster Fix wal_writer_flush_after initializer value. 2023-05-15 11:19:54 +12:00
regex Fix various typos 2023-04-18 13:23:23 +12:00
replication Fix invalid memory access during the shutdown of the parallel apply worker. 2023-05-09 09:28:06 +05:30
rewrite Make Vars be outer-join-aware. 2023-01-30 13:16:20 -05:00
snowball Update copyright for 2023 2023-01-02 15:00:37 -05:00
statistics Update copyright for 2023 2023-01-02 15:00:37 -05:00
storage Add writeback to pg_stat_io 2023-05-17 11:18:35 -07:00
tcop Update copyright for 2023 2023-01-02 15:00:37 -05:00
tsearch Update tsearch regex memory management. 2023-04-08 22:09:17 +12:00
utils pageinspect: Fix gist_page_items() with included columns 2023-05-19 12:37:58 +09:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
c.h Introduce PG_IO_ALIGN_SIZE and align all I/O buffers. 2023-04-08 16:34:50 +12:00
fmgr.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
funcapi.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
getopt_long.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
Makefile Include headers of archive/ in installation 2023-03-10 20:08:10 +09:00
meson.build Include headers of archive/ in installation 2023-03-10 20:08:10 +09:00
miscadmin.h Add VACUUM/ANALYZE BUFFER_USAGE_LIMIT option 2023-04-07 11:40:31 +12:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_ext.h.meson meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
pg_config_manual.h Fix typos in comments 2023-05-02 12:23:08 +09:00
pg_config.h.in Further cleanup of autoconf output files for GSSAPI changes. 2023-04-17 11:21:50 -04:00
pg_getopt.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_trace.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pgstat.h Add writeback to pg_stat_io 2023-05-17 11:18:35 -07:00
pgtar.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pgtime.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
port.h Add SHELL_ERROR and SHELL_EXIT_CODE magic variables to psql. 2023-03-21 13:03:56 -04:00
postgres_ext.h Move RelFileNumber declarations to common/relpath.h. 2022-09-27 12:01:57 -04:00
postgres_fe.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
postgres.h New header varatt.h split off from postgres.h 2023-01-10 05:54:36 +01:00
varatt.h New header varatt.h split off from postgres.h 2023-01-10 05:54:36 +01:00
windowapi.h Update copyright for 2023 2023-01-02 15:00:37 -05:00