Use multi-inserts for pg_depend
authorMichael Paquier <michael@paquier.xyz>
Sat, 5 Sep 2020 04:52:47 +0000 (13:52 +0900)
committerMichael Paquier <michael@paquier.xyz>
Sat, 5 Sep 2020 04:52:47 +0000 (13:52 +0900)
commit63110c6264a5363863209c8fbdd0498c03535507
tree2d45318cdc1112b1b30a2cc3bda9ee8736dcacea
parent4d41823c5267184fb021ac456caf95ef734cc8b0
Use multi-inserts for pg_depend

This is a follow-up of the work done in e3931d01.  This case is a bit
different than pg_attribute and pg_shdepend: the maximum number of items
to insert is known in advance, but there is no need to handle pinned
dependencies.  Hence, the base allocation for slots is done based on the
number of items and the maximum allowed with a cap at 64kB.  Slots are
initialized once used to minimize the overhead of the operation.

The insertions can be done for dependencies of the same type.  More
could be done by grouping the insertion of multiple dependency types in
a single batch.  This is left as future work.

Some of the multi-insert logic is also simplified for pg_shdepend, as
per the feedback discussed for this specific patch.  This also moves to
indexing.h the variable capping the maximum amount of data that can be
used at once for a multi-insert, instead of having separate definitions
for pg_attribute, pg_depend and pg_shdepend.

Author: Daniel Gustafsson, Michael Paquier
Reviewed-by: Andres Freund, Álvaro Herrera
Discussion: https://postgr.es/m/20200807061619.GA23955@paquier.xyz
src/backend/catalog/heap.c
src/backend/catalog/pg_depend.c
src/backend/catalog/pg_shdepend.c
src/include/catalog/indexing.h