Adjust design of per-worker parallel seqscan data struct
authorDavid Rowley <drowley@postgresql.org>
Mon, 29 Mar 2021 21:17:09 +0000 (10:17 +1300)
committerDavid Rowley <drowley@postgresql.org>
Mon, 29 Mar 2021 21:17:09 +0000 (10:17 +1300)
commitaf527705edc3fd0b335264d17e0521c05edc5cca
tree11f0d9972f7f2602394cc9b0ead1194a9515de2f
parent6d7a6feac48b1970c4cd127ee65d4c487acbb5e9
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: http://postgr.es/m/20210317023101.anvejcfotwka6gaa@alap3.anarazel.de
src/backend/access/heap/heapam.c
src/include/access/heapam.h
src/include/access/relscan.h