Skip to content

Heuristic to choose indexes for rebuild

The current approach is to select indexes at random for rebuilds. We can improve that, a few points we discussed are:

  1. Choose based on historical bloat levels (based on results of previous rebuilds). Choose indexes with historically high levels of bloat.
  2. Choose small indexes first, see #249662 (comment 420376511)
  3. Choose based on rebuild frequency (least frequently rebuilt first)
  4. Estimate index bloat and pick highly bloated indexes (by that estimate)
  5. Prioritize INVALID indexes to fix those along the way (!43834 (comment 421965514))
  6. ?

The goal here is to pick a strategy and implement that (one strategy, see how that works out).

Edited by Andreas Brandl