@@ -773,67 +773,6 @@ _bt_parallel_advance_array_keys(IndexScanDesc scan)
773
773
SpinLockRelease (& btscan -> btps_mutex );
774
774
}
775
775
776
- /*
777
- * _bt_vacuum_needs_cleanup() -- Checks if index needs cleanup
778
- *
779
- * Called by btvacuumcleanup when btbulkdelete was never called because no
780
- * tuples needed to be deleted by VACUUM.
781
- *
782
- * When we return false, VACUUM can even skip the cleanup-only call to
783
- * btvacuumscan (i.e. there will be no btvacuumscan call for this index at
784
- * all). Otherwise, a cleanup-only btvacuumscan call is required.
785
- */
786
- static bool
787
- _bt_vacuum_needs_cleanup (IndexVacuumInfo * info )
788
- {
789
- Buffer metabuf ;
790
- Page metapg ;
791
- BTMetaPageData * metad ;
792
- uint32 btm_version ;
793
- BlockNumber prev_num_delpages ;
794
-
795
- /*
796
- * Copy details from metapage to local variables quickly.
797
- *
798
- * Note that we deliberately avoid using cached version of metapage here.
799
- */
800
- metabuf = _bt_getbuf (info -> index , BTREE_METAPAGE , BT_READ );
801
- metapg = BufferGetPage (metabuf );
802
- metad = BTPageGetMeta (metapg );
803
- btm_version = metad -> btm_version ;
804
-
805
- if (btm_version < BTREE_NOVAC_VERSION )
806
- {
807
- /*
808
- * Metapage needs to be dynamically upgraded to store fields that are
809
- * only present when btm_version >= BTREE_NOVAC_VERSION
810
- */
811
- _bt_relbuf (info -> index , metabuf );
812
- return true;
813
- }
814
-
815
- prev_num_delpages = metad -> btm_last_cleanup_num_delpages ;
816
- _bt_relbuf (info -> index , metabuf );
817
-
818
- /*
819
- * Trigger cleanup in rare cases where prev_num_delpages exceeds 5% of the
820
- * total size of the index. We can reasonably expect (though are not
821
- * guaranteed) to be able to recycle this many pages if we decide to do a
822
- * btvacuumscan call during the ongoing btvacuumcleanup.
823
- *
824
- * Our approach won't reliably avoid "wasted" cleanup-only btvacuumscan
825
- * calls. That is, we can end up scanning the entire index without ever
826
- * placing even 1 of the prev_num_delpages pages in the free space map, at
827
- * least in certain narrow cases (see nbtree/README section on recycling
828
- * deleted pages for details). This rarely comes up in practice.
829
- */
830
- if (prev_num_delpages > 0 &&
831
- prev_num_delpages > RelationGetNumberOfBlocks (info -> index ) / 20 )
832
- return true;
833
-
834
- return false;
835
- }
836
-
837
776
/*
838
777
* Bulk deletion of all index entries pointing to a set of heap tuples.
839
778
* The set of target tuples is specified via a callback routine that tells
@@ -894,7 +833,7 @@ btvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
894
833
if (stats == NULL )
895
834
{
896
835
/* Check if VACUUM operation can entirely avoid btvacuumscan() call */
897
- if (!_bt_vacuum_needs_cleanup (info ))
836
+ if (!_bt_vacuum_needs_cleanup (info -> index ))
898
837
return NULL ;
899
838
900
839
/*
0 commit comments