scripts to check statistics of a database

echo "Enter the DB-NAME"
read dbname
PATH=/opt/PostgreSQL/9.6/bin:$PATH
PGDATA=/opt/PostgreSQL/9.6/data
PGDATABASE=postgres
PGUSER=postgres
PGPORT=5432
PGPASSWORD=postgres
DATE=$(date +%G-%m-%d--%H-%M-%S-%N)
LOGFILE=/tmp/DBLOGS/$dbname-DATE-$DATE.log
psql $dbname -c "select schemaname,relname,n_tup_ins,n_tup_upd,n_tup_del,n_dead_tup from pg_stat_user_tables order by n_dead_tup;" >>$LOGFILE

Comments

Popular Posts