2005-07-14 07:13:45 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* autovacuum.h
|
|
|
|
* header file for integrated autovacuum daemon
|
|
|
|
*
|
|
|
|
*
|
2024-01-04 02:49:05 +01:00
|
|
|
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
|
2005-07-14 07:13:45 +02:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/postmaster/autovacuum.h
|
2005-07-14 07:13:45 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef AUTOVACUUM_H
|
|
|
|
#define AUTOVACUUM_H
|
|
|
|
|
2017-04-03 22:17:45 +02:00
|
|
|
#include "storage/block.h"
|
|
|
|
|
BRIN auto-summarization
Previously, only VACUUM would cause a page range to get initially
summarized by BRIN indexes, which for some use cases takes too much time
since the inserts occur. To avoid the delay, have brininsert request a
summarization run for the previous range as soon as the first tuple is
inserted into the first page of the next range. Autovacuum is in charge
of processing these requests, after doing all the regular vacuuming/
analyzing work on tables.
This doesn't impose any new tasks on autovacuum, because autovacuum was
already in charge of doing summarizations. The only actual effect is to
change the timing, i.e. that it occurs earlier. For this reason, we
don't go any great lengths to record these requests very robustly; if
they are lost because of a server crash or restart, they will happen at
a later time anyway.
Most of the new code here is in autovacuum, which can now be told about
"work items" to process. This can be used for other things such as GIN
pending list cleaning, perhaps visibility map bit setting, both of which
are currently invoked during vacuum, but do not really depend on vacuum
taking place.
The requests are at the page range level, a granularity for which we did
not have SQL-level access; we only had index-level summarization
requests via brin_summarize_new_values(). It seems reasonable to add
SQL-level access to range-level summarization too, so add a function
brin_summarize_range() to do that.
Authors: Álvaro Herrera, based on sketch from Simon Riggs.
Reviewed-by: Thomas Munro.
Discussion: https://postgr.es/m/20170301045823.vneqdqkmsd4as4ds@alvherre.pgsql
2017-04-01 19:00:53 +02:00
|
|
|
/*
|
|
|
|
* Other processes can request specific work from autovacuum, identified by
|
|
|
|
* AutoVacuumWorkItem elements.
|
|
|
|
*/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
AVW_BRINSummarizeRange,
|
|
|
|
} AutoVacuumWorkItemType;
|
|
|
|
|
2007-04-16 20:30:04 +02:00
|
|
|
|
2005-07-14 07:13:45 +02:00
|
|
|
/* GUC variables */
|
2022-04-08 14:16:38 +02:00
|
|
|
extern PGDLLIMPORT bool autovacuum_start_daemon;
|
|
|
|
extern PGDLLIMPORT int autovacuum_max_workers;
|
|
|
|
extern PGDLLIMPORT int autovacuum_work_mem;
|
|
|
|
extern PGDLLIMPORT int autovacuum_naptime;
|
|
|
|
extern PGDLLIMPORT int autovacuum_vac_thresh;
|
|
|
|
extern PGDLLIMPORT double autovacuum_vac_scale;
|
|
|
|
extern PGDLLIMPORT int autovacuum_vac_ins_thresh;
|
|
|
|
extern PGDLLIMPORT double autovacuum_vac_ins_scale;
|
|
|
|
extern PGDLLIMPORT int autovacuum_anl_thresh;
|
|
|
|
extern PGDLLIMPORT double autovacuum_anl_scale;
|
|
|
|
extern PGDLLIMPORT int autovacuum_freeze_max_age;
|
|
|
|
extern PGDLLIMPORT int autovacuum_multixact_freeze_max_age;
|
|
|
|
extern PGDLLIMPORT double autovacuum_vac_cost_delay;
|
|
|
|
extern PGDLLIMPORT int autovacuum_vac_cost_limit;
|
2005-07-14 07:13:45 +02:00
|
|
|
|
2007-04-16 20:30:04 +02:00
|
|
|
/* autovacuum launcher PID, only valid when worker is shutting down */
|
2022-04-08 14:16:38 +02:00
|
|
|
extern PGDLLIMPORT int AutovacuumLauncherPid;
|
2007-04-16 20:30:04 +02:00
|
|
|
|
2022-04-08 14:16:38 +02:00
|
|
|
extern PGDLLIMPORT int Log_autovacuum_min_duration;
|
2007-04-18 18:44:18 +02:00
|
|
|
|
2005-07-14 07:13:45 +02:00
|
|
|
/* Status inquiry functions */
|
|
|
|
extern bool AutoVacuumingActive(void);
|
|
|
|
|
2024-03-18 10:35:08 +01:00
|
|
|
/* called from postmaster at server startup */
|
2005-07-14 07:13:45 +02:00
|
|
|
extern void autovac_init(void);
|
2007-11-15 22:14:46 +01:00
|
|
|
|
2007-06-25 18:09:03 +02:00
|
|
|
/* called from postmaster when a worker could not be forked */
|
|
|
|
extern void AutoVacWorkerFailed(void);
|
2005-07-14 07:13:45 +02:00
|
|
|
|
2024-03-18 10:35:08 +01:00
|
|
|
extern void AutoVacLauncherMain(char *startup_data, size_t startup_data_len) pg_attribute_noreturn();
|
|
|
|
extern void AutoVacWorkerMain(char *startup_data, size_t startup_data_len) pg_attribute_noreturn();
|
2005-07-14 07:13:45 +02:00
|
|
|
|
2018-03-14 15:53:56 +01:00
|
|
|
extern bool AutoVacuumRequestWork(AutoVacuumWorkItemType type,
|
BRIN auto-summarization
Previously, only VACUUM would cause a page range to get initially
summarized by BRIN indexes, which for some use cases takes too much time
since the inserts occur. To avoid the delay, have brininsert request a
summarization run for the previous range as soon as the first tuple is
inserted into the first page of the next range. Autovacuum is in charge
of processing these requests, after doing all the regular vacuuming/
analyzing work on tables.
This doesn't impose any new tasks on autovacuum, because autovacuum was
already in charge of doing summarizations. The only actual effect is to
change the timing, i.e. that it occurs earlier. For this reason, we
don't go any great lengths to record these requests very robustly; if
they are lost because of a server crash or restart, they will happen at
a later time anyway.
Most of the new code here is in autovacuum, which can now be told about
"work items" to process. This can be used for other things such as GIN
pending list cleaning, perhaps visibility map bit setting, both of which
are currently invoked during vacuum, but do not really depend on vacuum
taking place.
The requests are at the page range level, a granularity for which we did
not have SQL-level access; we only had index-level summarization
requests via brin_summarize_new_values(). It seems reasonable to add
SQL-level access to range-level summarization too, so add a function
brin_summarize_range() to do that.
Authors: Álvaro Herrera, based on sketch from Simon Riggs.
Reviewed-by: Thomas Munro.
Discussion: https://postgr.es/m/20170301045823.vneqdqkmsd4as4ds@alvherre.pgsql
2017-04-01 19:00:53 +02:00
|
|
|
Oid relationId, BlockNumber blkno);
|
|
|
|
|
2007-02-16 00:23:23 +01:00
|
|
|
/* shared memory stuff */
|
|
|
|
extern Size AutoVacuumShmemSize(void);
|
|
|
|
extern void AutoVacuumShmemInit(void);
|
|
|
|
|
2005-07-14 07:13:45 +02:00
|
|
|
#endif /* AUTOVACUUM_H */
|