• Home
  • Services
    • DBA Support
    • DBA Consultancy Services
    • PostgreSQL Support
    • Website Maintenance
  • Courses

    About Courses

    • List Of Courses
    • Become an Instructor
    Greenplum Database

    Greenplum Database

    $2,000.00 $1,500.00
    Read More
  • Company
    • FAQs
    • About Us
    • Contact
  • Events
  • Portfolio
  • Blogs
    • Blog – RayaFeeL
    • Blog – PostgreSQL Support
    • Blog – PostgreSQL Migration
    • Blog – All DB’s
    • Blog – Linux
    • Blog – Medical Coding
      • Cart

        0

    Have any question?
    (+91)8838953252
    ITsupport@rayafeel.com
    RegisterLogin
    RayaFeeL
    • Home
    • Services
      • DBA Support
      • DBA Consultancy Services
      • PostgreSQL Support
      • Website Maintenance
    • Courses

      About Courses

      • List Of Courses
      • Become an Instructor
      Greenplum Database

      Greenplum Database

      $2,000.00 $1,500.00
      Read More
    • Company
      • FAQs
      • About Us
      • Contact
    • Events
    • Portfolio
    • Blogs
      • Blog – RayaFeeL
      • Blog – PostgreSQL Support
      • Blog – PostgreSQL Migration
      • Blog – All DB’s
      • Blog – Linux
      • Blog – Medical Coding
        • Cart

          0

      Blog

      • Home
      • Blog
      • Blog
      • How to schedule VACUUM and ANALYZE script for for postgres database ?

      How to schedule VACUUM and ANALYZE script for for postgres database ?

      • Posted by 2ndnijam
      • Categories Blog
      • Date February 9, 2019
      • Comments 0 comment

      In this blog will be helpful to schedule vacuum script for postgres database by using crontab and you can monitor the postgres database dead tuble rows  by following script as per the dead tuble you can shedule vacuum by daily basis or weekly basis .

      Ans:
      1.Find out the vacuum level 

      \c chennai
      select count(*) from pg_stat_all_tables where n_dead_tup > 1000;
      
      \c mumbai
      select count(*) from pg_stat_all_tables where n_dead_tup > 1000;
      
      \c kolkatta
      select count(*) from pg_stat_all_tables where n_dead_tup > 1000;
      
      \c banglore
      select count(*) from pg_stat_all_tables where n_dead_tup > 1000;
      
      \c newyork
      select count(*) from pg_stat_all_tables where n_dead_tup > 1000;
      select schemaname,relname,n_dead_tup,last_vacuum,last_autovacuum, last_analyze, last_autoanalyze from pg_stat_all_tables;

      2.Script for Analyze and vacuum the postgresql dead tubles

       vi /home/script/vaccum_database.sh
      
      #!/bin/sh
      # The script sets environment variables helpful for PostgreSQL
      
      export PATH=/opt/PostgreSQL/9.6/bin:$PATH
      export PGDATA=/data/emut_96/
      export PGDATABASE=postgres
      export PGUSER=postgres
      export PGPORT=5432
      export PGLOCALEDIR=/opt/PostgreSQL/9.6/share/locale
      export MANPATH=$MANPATH:/opt/PostgreSQL/9.6/share/man
      
      
      vacuumdb --analyze chennai
      vacuumdb --analyze mumbai
      vacuumdb --analyze kolkatta
      vacuumdb --analyze banglore
      vacuumdb --analyze newyork

      3.vacuum analyze sheduling in crontab on  everyday of 10.pm

      befere scheduling crontjob check the current date.
      $ date
      
      crontab -e
      0 22 * * * sh /home/script/vaccum_database.sh

       

      • Share:
      2ndnijam

      Previous post

      script for VACUUM and ANALYZE for postgres database
      February 9, 2019

      Next post

      Easiest way to fix postgres data partition full without any data loss ?
      February 9, 2019

      Leave A Reply Cancel reply

      You must be logged in to post a comment.

      Login with:

      Login with Google Login with Twitter Login with LinkedIn Login with Microsoft


      Search

      ADVERTISEMENT

      Latest Posts

      PostgreSQL Patching version 9, 10,11
      10Oct2019
      Tools for PostgreSQL
      16Sep2019
      Postgres user creation and restrict DDL & database access
      13Sep2019
      PostgreSQL SSL Setup
      07Sep2019
      How to DELETE current XLOG / WAL LOG in postgresql database ?
      19Aug2019

      Latest Courses

      PostgreSQL Database

      PostgreSQL Database

      $600.00 $500.00
      Greenplum Database

      Greenplum Database

      $2,000.00 $1,500.00

      Preview Course

      Free

      Recent Forum Topics

      • thought behind whiteboard activity
      • Are you going to take your first ste
      • How to start working on an application?
      • please let me know pre requirements to increase work_mem
      • how to copy some data in one table to another table in postgres

      2ndquadrant.in

      (+91) 8838953252

      ITsupport@rayafeel.com

      Company

      • About Us
      • Contact
      • Our Team
      • Blog

      COURSES

      • List Of Course
      • Become An Instructor
      • Events
      • Postgres Support Blog

      Support

      • DBA Support
      • Consultancy Services
      • Postgres Migration Blogs
      • Forum

      Recommend

      • Groups
      • Login
      • FAQs
      • SignUp

      IT Services by rayafeel.com. Powered by Rayafeel Technologies Pvt Ltd.

      • Privacy
      • Terms

      Become An Instructor?

      Join thousand of instructors and earn money hassle free!

      Get Started Now

      Login with:

      Login with Google Login with Twitter Login with LinkedIn Login with Microsoft

      Login with your site account

      Lost your password?

      Not a member yet? Register now

      Register a new account

      Are you a member? Login now