Re: Skip index cleanup if autovacuum did not do any work

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Skip index cleanup if autovacuum did not do any work
Дата
Msg-id 10963.1511906103@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Skip index cleanup if autovacuum did not do any work  (Feike Steenbergen <feikesteenbergen@gmail.com>)
Ответы Re: Skip index cleanup if autovacuum did not do any work
Список pgsql-hackers
Feike Steenbergen <feikesteenbergen@gmail.com> writes:
> On a server with a very frequent xid wraparound I can see that the
> anti-wraparound vacuum is finished very quickly with the heap, yet it still
> scans all the indexes, which causes it to still have to read a lot of data,
> which takes a considerable amount of time.

> I dove into the code a bit and as far as I can tell, all the time spent for
> doing this is is in lazy_cleanup_index.

> For the very specific use case of all-frozen, basically read-only tables,
> would it be ok to skip the lazy_cleanup_index call? As we are sure we did
> not touch the heap or the index, I'd say a cleanup may not be necessary.

It's intentional that we call the index AM in any case.  Your patch
entirely forecloses the possibility that the AM might have work it
wants to do at VACUUM time independently of whether there were any
dead heap tuples.  (A handy example is GIN pushing stuff from its
fast-insert queue to the main index structure.)

It might be okay to put such a short-circuit in at a lower level,
eg within the btree AM.  I don't remember at the moment whether
a btree vacuum scan accomplishes anything much if there are no dead
tuples.

One thing that I think it does do is update the index's pg_class stats
(relpages/reltuples).  Maybe it's okay to skip that in this particular
scenario, trusting that auto-analyze would fix it, but that seems
worthy of debate.
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Feike Steenbergen
Дата:
Сообщение: Re: Skip index cleanup if autovacuum did not do any work
Следующее
От: Peter Geoghegan
Дата:
Сообщение: Re: Skip index cleanup if autovacuum did not do any work