mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
autovacuum: handle analyze for partitioned tables
Previously, autovacuum would completely ignore partitioned tables, which is not good regarding analyze -- failing to analyze those tables means poor plans may be chosen. Make autovacuum aware of those tables by propagating "changes since analyze" counts from the leaf partitions up the partitioning hierarchy. This also introduces necessary reloptions support for partitioned tables (autovacuum_enabled, autovacuum_analyze_scale_factor, autovacuum_analyze_threshold). It's unclear how best to document this aspect. Author: Yuzuko Hosoya <yuzukohosoya@gmail.com> Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Reviewed-by: Tomas Vondra <tomas.vondra@enterprisedb.com> Reviewed-by: Álvaro Herrera <alvherre@alvh.no-ip.org> Discussion: https://postgr.es/m/CAKkQ508_PwVgwJyBY=0Lmkz90j8CmWNPUxgHvCUwGhMrouz6UA@mail.gmail.com
This commit is contained in:
@ -108,7 +108,7 @@ static relopt_bool boolRelOpts[] =
|
||||
{
|
||||
"autovacuum_enabled",
|
||||
"Enables autovacuum in this relation",
|
||||
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
|
||||
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST | RELOPT_KIND_PARTITIONED,
|
||||
ShareUpdateExclusiveLock
|
||||
},
|
||||
true
|
||||
@ -246,7 +246,7 @@ static relopt_int intRelOpts[] =
|
||||
{
|
||||
"autovacuum_analyze_threshold",
|
||||
"Minimum number of tuple inserts, updates or deletes prior to analyze",
|
||||
RELOPT_KIND_HEAP,
|
||||
RELOPT_KIND_HEAP | RELOPT_KIND_PARTITIONED,
|
||||
ShareUpdateExclusiveLock
|
||||
},
|
||||
-1, 0, INT_MAX
|
||||
@ -420,7 +420,7 @@ static relopt_real realRelOpts[] =
|
||||
{
|
||||
"autovacuum_analyze_scale_factor",
|
||||
"Number of tuple inserts, updates or deletes prior to analyze as a fraction of reltuples",
|
||||
RELOPT_KIND_HEAP,
|
||||
RELOPT_KIND_HEAP | RELOPT_KIND_PARTITIONED,
|
||||
ShareUpdateExclusiveLock
|
||||
},
|
||||
-1, 0.0, 100.0
|
||||
@ -1962,12 +1962,11 @@ bytea *
|
||||
partitioned_table_reloptions(Datum reloptions, bool validate)
|
||||
{
|
||||
/*
|
||||
* There are no options for partitioned tables yet, but this is able to do
|
||||
* some validation.
|
||||
* autovacuum_enabled, autovacuum_analyze_threshold and
|
||||
* autovacuum_analyze_scale_factor are supported for partitioned tables.
|
||||
*/
|
||||
return (bytea *) build_reloptions(reloptions, validate,
|
||||
RELOPT_KIND_PARTITIONED,
|
||||
0, NULL, 0);
|
||||
|
||||
return default_reloptions(reloptions, validate, RELOPT_KIND_PARTITIONED);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user