ANALYZE counts LP_DEAD line pointers as n_dead_tup

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: ANALYZE counts LP_DEAD line pointers as n_dead_tup
Date: 2021-04-14 14:10:37
Message-ID: CAD21AoBwkgvxiR13Atr=49TFf_thvZttzOsVZp-eRu8Bz+u9dg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

If we create a table with vacuum_index_cleanup = off or execute VACUUM
with INDEX_CLEANUP = off, vacuum updates pg_stat_all_tables.n_dead_tup
to the number of HEAPTUPLE_RECENTLY_DEAD tuples. Whereas analyze
updates it to the sum of the number of HEAPTUPLE_DEAD/RECENTLY_DEAD
tuples and LP_DEAD line pointers. So if the table has many LP_DEAD
line pointers due to skipping index cleanup, autovacuum is triggered
every time after analyze/autoanalyze. This issue seems to happen also
on back branches, probably from 12 where INDEX_CLEANUP option was
introduced.

I think we can have heapam_scan_analyze_next_tuple() not count LP_DEAD
line pointer as lazy_scan_prune() does. Attached the patch for that.

Regards,

--
Masahiko Sawada
EDB: https://www.enterprisedb.com/

Attachment Content-Type Size
not_count_lp_dead_by_analyze.patch application/octet-stream 1022 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mead, Scott 2021-04-14 14:17:45 Re: [BUG] Autovacuum not dynamically decreasing cost_limit and cost_delay
Previous Message Bharath Rupireddy 2021-04-14 14:06:06 Can a child process detect postmaster death when in pg_usleep?