From a6151eae698c238ee4d978d161e1f826c0956fa9 Mon Sep 17 00:00:00 2001 From: Amit Kapila Date: Tue, 26 Nov 2019 17:02:29 +0530 Subject: [PATCH] fix stats issue. --- src/backend/access/heap/vacuumlazy.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index 17598a126a..11a167afd0 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -2073,6 +2073,9 @@ lazy_parallel_vacuum_or_cleanup_indexes(LVRelStats *vacrelstats, Relation *Irel, for (i = 0; i < nindexes; i++) { + LVSharedIndStats *shared_indstats; + IndexBulkDeleteResult *bulkdelete_res; + bool processed = !skip_parallel_index_vacuum(Irel[i], lps->lvshared->for_cleanup, lps->lvshared->first_time); @@ -2081,6 +2084,24 @@ lazy_parallel_vacuum_or_cleanup_indexes(LVRelStats *vacrelstats, Relation *Irel, if (processed) continue; + /* Get index statistics struct of this index */ + shared_indstats = get_indstats(lps->lvshared, i); + + /* Skip if this index doesn't support parallel index vacuuming */ + if (shared_indstats != NULL) + { + + /* Get the space for IndexBulkDeleteResult */ + bulkdelete_res = GetIndexBulkDeleteResult(shared_indstats); + + /* + * Update the pointer to the corresponding bulk-deletion result + * if someone has already updated it. + */ + if (shared_indstats->updated && stats[i] == NULL) + stats[i] = bulkdelete_res; + } + if (lps->lvshared->for_cleanup) lazy_cleanup_index(Irel[i], &stats[i], vacrelstats->new_rel_tuples, @@ -3239,7 +3260,7 @@ get_indstats(LVShared *lvshared, int n) return NULL; p = (char *) GetSharedIndStats(lvshared); - for (i = 0; i < (n - 1); i++) + for (i = 0; i < n; i++) { if (IndStatsIsNull(lvshared, i)) continue; -- 2.16.2.windows.1