Monitoring object usage?

Started by Colin 't Hartover 15 years ago3 messagesgeneral
Jump to latest
#1Colin 't Hart
colinthart@gmail.com

Hi,

I'm trying to get a grip on a new body of code and a Postgres database that
I'm working with. In particular I've been tasked with cleaning up the
database.

Is there a way in Postgres to enable monitoring on tables and columns to
determine what's not actively being used?

This would then form input for a more thorough check into the code base to
see what's really not being used.

Thanks & cheers,

Colin

#2Jayadevan M
Jayadevan.Maymala@ibsplc.com
In reply to: Colin 't Hart (#1)
Re: Monitoring object usage?

Hi,

From: "Colin 't Hart" <colinthart@gmail.com>
To: pgsql-general@postgresql.org
Date: 15/09/2010 17:37
Subject: [GENERAL] Monitoring object usage?
Sent by: pgsql-general-owner@postgresql.org

Hi,

I'm trying to get a grip on a new body of code and a Postgres
database that I'm working with. In particular I've been tasked with
cleaning up the database.

Is there a way in Postgres to enable monitoring on tables and
columns to determine what's not actively being used?

This would then form input for a more thorough check into the code
base to see what's really not being used.

Would the log_statement mentioned here help?
http://www.postgresql.org/docs/current/static/runtime-config-logging.html
I guess it will result in huge log files if it is a 'busy' database.
Probably this has a performance penalty too.

Regards,
Jayadevan

DISCLAIMER:

"The information in this e-mail and any attachment is intended only for
the person to whom it is addressed and may contain confidential and/or
privileged material. If you have received this e-mail in error, kindly
contact the sender and destroy all copies of the original communication.
IBS makes no warranty, express or implied, nor guarantees the accuracy,
adequacy or completeness of the information contained in this email or any
attachment and is not liable for any errors, defects, omissions, viruses
or for resultant loss or damage, if any, direct or indirect."

#3Tomas Vondra
tomas.vondra@2ndquadrant.com
In reply to: Colin 't Hart (#1)
Re: Monitoring object usage?

Well, you can see usage statistics for tables, indexes, functions and
sequences ... but AFAIK it's not possible to do that for columns.

See this
http://www.postgresql.org/docs/8.4/static/runtime-config-statistics.html
and then use pg_stat_ and pg_statio_ catalogs
(http://www.postgresql.org/docs/8.4/static/monitoring-stats.html) to find
objects that were not accessed recently (numbers are 0 or do not change
anymore, etc.).

But be careful as this may backfire quite easily - imagine an index that's
used only in a batch processing the end of month. You could easily decide
it's not necessary and drop it, causing a disaster.

Tomas

Show quoted text

Hi,

I'm trying to get a grip on a new body of code and a Postgres database
that
I'm working with. In particular I've been tasked with cleaning up the
database.

Is there a way in Postgres to enable monitoring on tables and columns to
determine what's not actively being used?

This would then form input for a more thorough check into the code base to
see what's really not being used.

Thanks & cheers,

Colin