On Tue, Apr 21, 2020 at 2:25 PM Kevin Brannen <kbran...@efji.com> wrote:

> Sometimes I need the disk space back. It also makes me feel better. (OK,
> this may not a good reason but there is a hint of truth in this.) What this
> probably means is that I need to get a better understanding of vacuuming.
>

Imagine you have an auto-expanding array and also that individual cells can
be reused if the data in them is removed first.  Deletion marks a cell as
needing to be cleaned up (i.e., data removed).  Vacuum actually performs
the cleaning.  Insertion causes the system to either provide an existing,
cleaned/empty, cell OR to add a new cell to the end of the array and
provide that.  The longer the deleted cells go uncleaned the more cells
that are added onto the end of the array and the more physical space the
array takes up.  If you clean up the deleted cells more frequently they can
be reused in lieu of expanding the array.

Vacuum full counts the number of non-empty cells in the array, creates a
new array with that many cells, and writes the non-empty values into it -
then removes the old array.

Immediately after you perform a normal vacuum you have lots of empty cells
- but you know that the space is going to be filled in again soon so it
doesn't normally make sense to "resize the array".

David J.

Reply via email to