On Mon, Feb 26, 2018 at 11:31 AM, Claudio Freire <klaussfre...@gmail.com> wrote: >> ---- >> + /* >> + * If there are no indexes then we should periodically >> vacuum the FSM >> + * on huge relations to make free space visible early. >> + */ >> + if (nindexes == 0 && >> + (vacuumed_pages - vacuumed_pages_at_fsm_vac) > >> vacuum_fsm_every_pages) >> + { >> + /* Vacuum the Free Space Map */ >> + FreeSpaceMapVacuum(onerel, max_freespace); >> + vacuumed_pages_at_fsm_vac = vacuumed_pages; >> + max_freespace = 0; >> + } >> >> I think this code block should be executed before we check if the page >> is whether new or empty and then do 'continue'. Otherwise we cannot >> reach this code if the table has a lot of new or empty pages. > > In order for the counter (vacuumed_pages) to increase, there have to > be plenty of opportunities for this code to run, and I specifically > wanted to avoid vacuuming the FSM too often for those cases > particularly (when Vacuum scans lots of pages but does no writes).
Wait, I see what you mean. Entirely empty pages. Ok, I can move it.