2004-10-16 23:50:02 +02:00
/* pg_autovacuum.h
2003-03-20 19:14:46 +01:00
* Header file for pg_autovacuum . c
* ( c ) 2003 Matthew T . O ' Connor
2004-10-16 23:50:02 +02:00
*
2004-12-02 23:48:10 +01:00
* $ PostgreSQL : pgsql / contrib / pg_autovacuum / pg_autovacuum . h , v 1.14 2004 / 12 / 02 22 : 48 : 10 momjian Exp $
2003-03-20 19:14:46 +01:00
*/
2003-06-12 03:36:44 +02:00
2004-10-16 23:50:02 +02:00
# ifndef _PG_AUTOVACUUM_H
# define _PG_AUTOVACUUM_H
2004-08-30 05:31:29 +02:00
2003-05-14 05:27:22 +02:00
# include "libpq-fe.h"
2003-03-20 19:14:46 +01:00
# include "lib/dllist.h"
2004-08-30 05:31:29 +02:00
# define AUTOVACUUM_DEBUG 0
2003-08-04 02:43:34 +02:00
# define VACBASETHRESHOLD 1000
# define VACSCALINGFACTOR 2
# define SLEEPBASEVALUE 300
# define SLEEPSCALINGFACTOR 2
# define UPDATE_INTERVAL 2
2003-06-12 03:36:44 +02:00
/* these two constants are used to tell update_table_stats what operation we just perfomred */
2003-08-04 02:43:34 +02:00
# define VACUUM_ANALYZE 0
# define ANALYZE_ONLY 1
2003-06-12 03:36:44 +02:00
2003-09-13 18:26:18 +02:00
2004-08-30 05:31:29 +02:00
# define TABLE_STATS_QUERY "select a.oid,a.relname,a.relnamespace,a.relpages,a.relisshared,a.reltuples,b.schemaname,b.n_tup_ins,b.n_tup_upd,b.n_tup_del from pg_class a, pg_stat_all_tables b where a.oid=b.relid and a.relkind = 'r'"
2004-03-15 17:17:30 +01:00
# define PAGES_QUERY "select oid,reltuples,relpages from pg_class where oid=%u"
2003-06-12 03:36:44 +02:00
# define FROZENOID_QUERY "select oid,age(datfrozenxid) from pg_database where datname = 'template1'"
# define FROZENOID_QUERY2 "select oid,datname,age(datfrozenxid) from pg_database where datname!='template0'"
2003-03-20 19:14:46 +01:00
2004-08-30 05:31:29 +02:00
/* Log levels */
enum
{
LVL_DEBUG = 1 ,
LVL_INFO ,
LVL_WARNING ,
LVL_ERROR ,
LVL_EXTRA
} ;
2003-06-12 03:36:44 +02:00
/* define cmd_args stucture */
2004-10-16 23:50:02 +02:00
typedef struct cmdargs
2003-06-12 03:36:44 +02:00
{
2003-08-04 02:43:34 +02:00
int vacuum_base_threshold ,
analyze_base_threshold ,
sleep_base_value ,
debug ,
2004-11-17 17:54:15 +01:00
/*
* Cost - Based Vacuum Delay Settings for pg_autovacuum
*/
av_vacuum_cost_delay ,
av_vacuum_cost_page_hit ,
av_vacuum_cost_page_miss ,
av_vacuum_cost_page_dirty ,
av_vacuum_cost_limit ,
2004-08-30 05:31:29 +02:00
# ifndef WIN32
2003-08-04 02:43:34 +02:00
daemonize ;
2004-08-30 05:31:29 +02:00
# else
install_as_service ,
remove_as_service ;
# endif
2003-08-04 02:43:34 +02:00
float vacuum_scaling_factor ,
analyze_scaling_factor ,
sleep_scaling_factor ;
char * user ,
* password ,
2004-08-30 05:31:29 +02:00
# ifdef WIN32
2004-12-02 23:48:10 +01:00
* service_dependencies ,
2004-08-30 05:31:29 +02:00
* service_user ,
* service_password ,
# endif
2003-08-04 02:43:34 +02:00
* host ,
* logfile ,
* port ;
2004-10-16 23:50:02 +02:00
} cmd_args ;
2003-03-20 19:14:46 +01:00
2004-10-16 23:50:02 +02:00
/*
* Might need to add a time value for last time the whole database was
* vacuumed . We need to guarantee this happens approx every 1 Billion TX ' s
*/
typedef struct dbinfo
2003-06-12 03:36:44 +02:00
{
2004-03-15 17:17:30 +01:00
Oid oid ;
long age ;
long analyze_threshold ,
2003-08-04 02:43:34 +02:00
vacuum_threshold ; /* Use these as defaults for table
* thresholds */
PGconn * conn ;
char * dbname ,
* username ,
* password ;
Dllist * table_list ;
2004-10-16 23:50:02 +02:00
} db_info ;
2003-06-12 03:36:44 +02:00
2004-10-16 23:50:02 +02:00
typedef struct tableinfo
2003-06-12 03:36:44 +02:00
{
2003-08-04 02:43:34 +02:00
char * schema_name ,
* table_name ;
2004-03-15 17:17:30 +01:00
float reltuples ;
int relisshared ;
Oid relid ,
2003-08-04 02:43:34 +02:00
relpages ;
long analyze_threshold ,
vacuum_threshold ;
long CountAtLastAnalyze ; /* equal to: inserts + updates as
* of the last analyze or initial
* values at startup */
long CountAtLastVacuum ; /* equal to: deletes + updates as
* of the last vacuum or initial
* values at startup */
long curr_analyze_count ,
curr_vacuum_count ; /* Latest values from stats system */
db_info * dbi ; /* pointer to the database that this table
* belongs to */
2004-10-16 23:50:02 +02:00
} tbl_info ;
2003-03-20 19:14:46 +01:00
2004-10-16 23:50:02 +02:00
# endif /* _PG_AUTOVACUUM_H */