If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > Identifying the critical tables for manually vacuum

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-09-11, 02:28
zeelumak zeelumak is offline
Registered User
 
Join Date: Dec 2011
Posts: 2
Identifying the critical tables for manually vacuum

Hi,

I am new to postgres and i have a task to find out the tables which need to be manually vacuumed in case of vacuum process lagging behind..
Can you please help me out

Thanks
Reply With Quote
  #2 (permalink)  
Old 12-09-11, 03:01
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
What exactly do you mean with "lagging behind"? You can find out when tables were vacuumed the last time using this:
Code:
select relname,last_vacuum, last_autovacuum, last_analyze, last_autoanalyze 
from pg_stat_user_tables;
Is that what you had in mind?

I don't think you can find out if a table needs vacuum unless you run a vacuum on them. But I might be mistaken.

Last edited by shammat; 12-09-11 at 04:19.
Reply With Quote
  #3 (permalink)  
Old 12-09-11, 04:01
zeelumak zeelumak is offline
Registered User
 
Join Date: Dec 2011
Posts: 2
Thanks for your prompt reply.

But, I am looking for some thing which gives me the list of tables.
For example here is the scenario:

When you run the query once a day

select datname, age(datfrozenxid) from pg_database;

If you find the datfrozenxid is increasing then it means the auto vacuuming process is lagging behind. This will cause a transaction xid wrap around soon and will result in force shut down of the postgres.

So, When i find the age of the datfrozenxid is increasing I want to check the tables and manually vacuum the tables.


I hope this is clear

Thanks
Reply With Quote
  #4 (permalink)  
Old 12-09-11, 08:27
arvindps arvindps is offline
Registered User
 
Join Date: Aug 2011
Posts: 27
Look into pg_stat_all_tables

and see column- n_dead_tup

if the figure is high in comparison with total rows, then this means this table requires
vacumming.

how much is the % , is matter of internal policy. But it is safe to assume anything above 4% is a need-to-vaccum
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On