From 1113e7d0d524e912be0e1959e50bd0d27c9b5381 Mon Sep 17 00:00:00 2001 From: Amit Kapila Date: Fri, 22 Nov 2019 14:24:18 +0530 Subject: [PATCH] Fixed issues and added comments. --- doc/src/sgml/indexam.sgml | 13 +++++++------ src/backend/access/index/indexam.c | 6 ++---- src/include/access/amapi.h | 8 ++++---- src/include/commands/vacuum.h | 29 +++++++++++++++++++++-------- 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/doc/src/sgml/indexam.sgml b/doc/src/sgml/indexam.sgml index 693171dc4f..9fed438fc6 100644 --- a/doc/src/sgml/indexam.sgml +++ b/doc/src/sgml/indexam.sgml @@ -154,7 +154,7 @@ typedef struct IndexAmRoutine aminitparallelscan_function aminitparallelscan; /* can be NULL */ amparallelrescan_function amparallelrescan; /* can be NULL */ - /* interface functions to support parallel vacuum */ + /* interface function to support parallel vacuum */ amestimateparallelvacuum_function amestimateparallelvacuum; /* can be NULL */ } IndexAmRoutine; @@ -740,17 +740,18 @@ amparallelrescan (IndexScanDesc scan); -void -amestimateparallelvacuum (IndexScanDesc scan); +Size +amestimateparallelvacuum (void); - Estimate and return the number of bytes of dynamic shared memory which the - access method will be needed to copy the statistics to. + Estimate and return the number of bytes of dynamic shared memory needed to + store statistics returned by the access method. It is not necessary to implement this function for access methods which do not support parallel vacuum or in cases where the access method does not - require more than size of IndexBulkDeleteResult. + require more than size of IndexBulkDeleteResult to + store statistics. diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index 4801c326be..d176f0193b 100644 --- a/src/backend/access/index/indexam.c +++ b/src/backend/access/index/indexam.c @@ -712,11 +712,9 @@ index_vacuum_cleanup(IndexVacuumInfo *info, } /* - * index_parallelvacuum_estimate - estimate shared memory for parallel vacuum + * index_parallelvacuum_estimate * - * Currently, we don't pass any information to the AM-specific estimator, - * so it can probably only return a constant. In the future, we might need - * to pass more information. + * Estimates the DSM space needed to store statistics for parallel vacuum. */ Size index_parallelvacuum_estimate(Relation indexRelation) diff --git a/src/include/access/amapi.h b/src/include/access/amapi.h index 0fd399442d..eb23f01ab6 100644 --- a/src/include/access/amapi.h +++ b/src/include/access/amapi.h @@ -157,9 +157,9 @@ typedef void (*aminitparallelscan_function) (void *target); typedef void (*amparallelrescan_function) (IndexScanDesc scan); /* - * Callback function signatures - for parallel index vacuuming. + * Callback function signature - for parallel index vacuuming. */ -/* estimate size of parallel index vacuuming memory */ +/* estimate size of statitics needed for parallel index vacuum */ typedef Size (*amestimateparallelvacuum_function) (void); /* @@ -203,7 +203,7 @@ typedef struct IndexAmRoutine bool amcanparallel; /* does AM support columns included with clause INCLUDE? */ bool amcaninclude; - /* OR of parallel vacuum flags */ + /* OR of parallel vacuum flags. See vacuum.h for flags. */ uint8 amparallelvacuumoptions; /* does AM use maintenance_work_mem? */ bool amusemaintenanceworkmem; @@ -241,7 +241,7 @@ typedef struct IndexAmRoutine aminitparallelscan_function aminitparallelscan; /* can be NULL */ amparallelrescan_function amparallelrescan; /* can be NULL */ - /* interface functions to support parallel vacuum */ + /* interface function to support parallel vacuum */ amestimateparallelvacuum_function amestimateparallelvacuum; /* can be NULL */ } IndexAmRoutine; diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h index 7b6f269785..508d5762ae 100644 --- a/src/include/commands/vacuum.h +++ b/src/include/commands/vacuum.h @@ -24,28 +24,41 @@ #include "utils/relcache.h" /* - * Flags amparallelvacuumoptions to control participation - * of bulkdelete and vacuumcleanup. Both are disabled by - * default. + * Flags to control the participation of bulkdelete and vacuumcleanup in + * parallel vacuum. + */ + +/* + * Both bulkdelete and vacuumcleanup are disabled by default. This will be + * used by IndexAM's that don't want to participate in parallel vacuum. */ #define VACUUM_OPTION_NO_PARALLEL 0 -/* bulkdelete can be performed in parallel */ +/* + * bulkdelete can be performed in parallel. This option can be used by + * IndexAm's that need to scan the index to delete the tuples. + */ #define VACUUM_OPTION_PARALLEL_BULKDEL (1 << 0) /* - * vacuumcleanup can be performed in parallel if bulkdelete is - * not performed yet. + * vacuumcleanup can be performed in parallel if bulkdelete is not performed + * yet. This will be used by IndexAM's that can scan the index if the + * bulkdelete is not performed. */ #define VACUUM_OPTION_PARALLEL_COND_CLEANUP (1 << 1) -/* vacuumcleanup can be performed in parallel */ +/* + * vacuumcleanup can be performed in parallel even if bulkdelete has already + * processed the index. This will be used by IndexAM's that scan the index + * during the cleanup phase of index irrespective of whether the index is + * already scanned or not during bulkdelete phase. + */ #define VACUUM_OPTION_PARALLEL_CLEANUP (1 << 2) /* value for checking vacuum flags */ #define VACUUM_OPTION_MAX_VALID_VALUE ((1 << 3) - 1) -/* Macros for parallel vacuum options */ +/* macros for parallel vacuum options */ #define VACUUM_OPTION_SUPPORT_PARALLEL_BULKDEL(flag) \ ((((flag) & VACUUM_OPTION_PARALLEL_BULKDEL)) != 0) #define VACUUM_OPTION_SUPPORT_PARALLEL_CLEANUP(flag) \ -- 2.16.2.windows.1