pgsql: Adjust design of per-worker parallel seqscan data struct - Mailing list pgsql-committers

From David Rowley
Subject pgsql: Adjust design of per-worker parallel seqscan data struct
Date
Msg-id E1lQzGX-0002mJ-FV@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Adjust design of per-worker parallel seqscan data struct

The design of the data structures which allow storage of the per-worker
memory during parallel seq scans were not ideal. The work done in
56788d215 required an additional data structure to allow workers to
remember the range of pages that had been allocated to them for
processing during a parallel seqscan.  That commit added a void pointer
field to TableScanDescData to allow heapam to store the per-worker
allocation information.  However putting the field there made very little
sense given that we have AM specific structs for that, e.g.
HeapScanDescData.

Here we remove the void pointer field from TableScanDescData and add a
dedicated field for this purpose to HeapScanDescData.

Previously we also allocated memory for this parallel per-worker data for
all scans, regardless if it was a parallel scan or not.  This was just a
wasted allocation for non-parallel scans, so here we make the allocation
conditional on the scan being parallel.

Also, add previously missing pfree() to free the per-worker data in
heap_endscan().

Reported-by: Andres Freund
Reviewed-by: Andres Freund
Discussion: https://postgr.es/m/20210317023101.anvejcfotwka6gaa@alap3.anarazel.de

Branch
------
master

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

Modified Files
--------------
src/backend/access/heap/heapam.c | 22 ++++++++++++++++------
src/include/access/heapam.h      |  6 ++++++
src/include/access/relscan.h     |  1 -
3 files changed, 22 insertions(+), 7 deletions(-)


pgsql-committers by date:

Previous
From: Andrew Dunstan
Date:
Subject: pgsql: Allow matching the DN of a client certificate for authentication
Next
From: Alvaro Herrera
Date:
Subject: pgsql: psql: call clearerr() just before printing