Re: Inspecting a DB - psql or system tables ?

From: Greg Smith <greg(at)2ndQuadrant(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Inspecting a DB - psql or system tables ?
Date: 2011-05-29 02:45:52
Message-ID: 4DE1B360.4080801@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 05/27/2011 01:24 PM, Andre Majorel wrote:
> While parsing the output of psql is cumbersome, accessing the
> system tables seems more likely to break whenever a new version
> of PostgreSQL comes out.
>

I think you have this backwards. If there's a change in this area big
enough to justify changing the format of the system tables, odds are the
text output from psql is going to be changed too. psql gets tweaked to
display information better more often than the internals are altered.

Approaches you can take here, from most robust in the face of changes to
most fragile, in my mind are:

1) Use information_schema. If all the info you need is in here, great;
it may not be though.
2) Use the system catalog data directly
3) Parse text output from psql.

--
Greg Smith 2ndQuadrant US greg(at)2ndQuadrant(dot)com Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.us
"PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Greg Smith 2011-05-29 02:54:24 Re: SELECT COUNT(*) execution time on large tables (v9.0.4-1)
Previous Message Edison So 2011-05-29 02:44:56 Re: max_connections proposal