pg_avd README

pg_avd is a libpq client program that monitors all the databases of a postgresql
server.  It uses the stats collector to monitor insert, update and delete
activity.  When a particular table exceeds the threshold then that table is
vacuumed and analyzed.  This allows the system to keep the fsm and table
statistics up to date without having to periodically vacuums with cron
whether they are needed or not.

Install:
To use pg_avd, uncompress the tar.gz into the src/bin directory and modify the
src/bin/Makefile to include the pg_avd directory.  pg_avd will then be made as
part of the standard postgresql install.

make sure that the folowing are set in postgresql.conf
stats_start_collector = true
stats_row_level = true

start up the postmaster
then, just execute the pg_avd executable.


Command line arguments:
pg_avd has the following optional arguments:
-d debug: setting debug = 0 will keep pg_avd quiet.
-s sleep base value: see "Sleeping" below.
-S sleep scaling factor: see "Sleeping" below.
-t tuple base threshold: see Vacuuming.
-T tuple scaling factor: see Vacuuming.
-U username: Username pg_avd will use to connect with, if not specified the
   current username is used
-P password: Password pg_avd will use to connect with.
-H host: host name or IP to connect too.
-p port: port used for connection.
-h help: list of command line options.

All arguments have default values defined in pg_avd.h.  At the time of this
writing they are:
#define AVD_DEBUG           1
#define BASETHRESHOLD       100
#define SCALINGFACTOR       2
#define SLEEPVALUE          3
#define SLEEPSCALINGFACTOR  2
#define UPDATE_INTERVAL     2


Vacuuming:
pg_avd vacuums a table whenever the number of inserts, updates or deletes
exceeds the threshold.  pg_avd uses two factors to determine the threshold for a
particular table: tuple_base_threshold and tuple_scaling_factor.
Vacuum Threshold is equal to:
tuple_base_value + (tuple_scaling_factor * "number of tuples in the table")

Sleeping:
pg_avd sleeps after it is done checking all the databases.  It does this so that
it doesn't consume too many system resources.  This allows the system
administrator to configure pg_avd to be more or less aggressive.
The total time it sleeps is equal to:
base_sleep_value + sleep_scaling_factor * "duration of the previous loop"

What it monitors:
pg_avd dynamically generates a list of databases and tables to monitor, in
addition it will dynamically add and remove databases and tables that are
removed from the database server while pg_avd is running.
