postgresql/src/backend/commands
Peter Geoghegan 74388a1ac3 Avoid VACUUM reltuples distortion.
Add a heuristic that avoids distortion in the pg_class.reltuples
estimates used by VACUUM.  Without the heuristic, successive manually
run VACUUM commands (run against a table that is never modified after
initial bulk loading) will scan the same page in each VACUUM operation.
Eventually pg_class.reltuples may reach the point where one single heap
page is accidentally considered highly representative of the entire
table.  This is likely to be completely wrong, since the last heap page
typically has fewer tuples than average for the table.

It's not obvious that this was a problem prior to commit 44fa8488, which
made vacuumlazy.c consistently scan the last heap page (even when it is
all-visible in the visibility map).  It seems possible that there were
more subtle variants of the same problem that went unnoticed for quite
some time, though.  Commit 44fa8488 simplified certain aspects of when
and how relation truncation was considered, but it did not introduce the
"scan the last page" behavior.  Essentially the same behavior was
introduced much earlier, in commit e8429082.  It was conditioned on
whether or not truncation looked promising towards the end of the
initial heap pass by VACUUM until recently, which was at least somewhat
protective.  That doesn't seem like something that we should be relying
on, though.

Author: Peter Geoghegan <pg@bowt.ie>
Discussion: https://postgr.es/m/CAH2-WzkNKORurux459M64mR63Aw4Jq7MBRVcX=CvALqN3A88WA@mail.gmail.com
2022-02-16 17:15:50 -08:00
..
Makefile Move parallel vacuum code to vacuumparallel.c. 2021-12-23 11:42:52 +05:30
aggregatecmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
alter.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
amcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
analyze.c Add VACUUM instrumentation for scanned pages, relfrozenxid. 2022-02-11 16:48:40 -08:00
async.c Reduce more the number of calls to GetMaxBackends() 2022-02-10 10:27:29 +09:00
cluster.c Consolidate VACUUM xid cutoff logic. 2022-02-11 18:26:15 -08:00
collationcmds.c Change collate and ctype fields to type text 2022-01-27 08:54:25 +01:00
comment.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
constraint.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
conversioncmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
copy.c Add HEADER support to COPY text format 2022-01-28 09:44:47 +01:00
copyfrom.c Remove redundant memory context switches in BeginCopyFrom(). 2022-01-19 12:31:15 -05:00
copyfromparse.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
copyto.c Fix incorrect memory context switch in COPY TO execution 2022-01-29 10:22:42 +09:00
createas.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
dbcommands.c Database-level collation version tracking 2022-02-14 08:27:26 +01:00
define.c Add Boolean node 2022-01-17 10:38:23 +01:00
discard.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
dropcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
event_trigger.c Remove all traces of tuplestore_donestoring() in the C code 2022-02-17 09:52:02 +09:00
explain.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
extension.c Remove all traces of tuplestore_donestoring() in the C code 2022-02-17 09:52:02 +09:00
foreigncmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
functioncmds.c Add Boolean node 2022-01-17 10:38:23 +01:00
indexcmds.c Add UNIQUE null treatment option 2022-02-03 11:48:21 +01:00
lockcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
matview.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
opclasscmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
operatorcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
policy.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
portalcmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
prepare.c Remove all traces of tuplestore_donestoring() in the C code 2022-02-17 09:52:02 +09:00
proclang.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
publicationcmds.c Fix various typos, grammar and code style in comments and docs 2022-01-25 09:40:04 +09:00
schemacmds.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
seclabel.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
sequence.c Logical decoding of sequences 2022-02-10 18:43:51 +01:00
statscmds.c Check syscache result in AlterStatistics 2022-01-23 03:16:31 +01:00
subscriptioncmds.c Fix various typos, grammar and code style in comments and docs 2022-01-25 09:40:04 +09:00
tablecmds.c Remove xloginsert.h from xlog.h 2022-01-30 12:25:24 -03:00
tablespace.c Fix DROP {DATABASE,TABLESPACE} on Windows. 2022-02-12 10:21:23 +13:00
trigger.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
tsearchcmds.c Add Boolean node 2022-01-17 10:38:23 +01:00
typecmds.c Add missing TYPEALIGN macros 2022-02-16 19:33:28 +07:00
user.c Add Boolean node 2022-01-17 10:38:23 +01:00
vacuum.c Avoid VACUUM reltuples distortion. 2022-02-16 17:15:50 -08:00
vacuumparallel.c Unify VACUUM VERBOSE and autovacuum logging. 2022-01-14 16:50:34 -08:00
variable.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
view.c Reject change of output-column collation in CREATE OR REPLACE VIEW. 2022-02-15 12:57:44 -05:00