Re: [HACKERS] Tupple statistics function

From: "Thurstan R(dot) McDougle" <trmcdougle(at)my-deja(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: [HACKERS] Tupple statistics function
Date: 2001-09-24 10:40:37
Message-ID: 3BAF0DA5.E4E3E9DE@my-deja.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Bruce Momjian wrote:
>
> > Hi,
> >
> > I have written a small function that show how many tuples are dead
> > etc. in a specified table. Example output is:
> >
> > test=# select pgstattuple('tellers');
> > NOTICE: physical length: 0.02MB live tuples: 200 (0.01MB, 58.59%) dead tuples: 100 (0.00MB, 29.30%) overhead: 12.11%
> > pgstattuple
> > -------------
> > 29.296875
> > (1 row)
> >
> > Shall I add this function into contrib directory?
>
> I have been wanting this for a long time. In fact, I wanted it linked
> to VACUUM so you could vacuum a table only if it had >X% dead tuples.
> Seems we can find a place for this in the existing commands. Not sure
> where, though. Ideas?

If you mean the reporting of stats how about EXPLAIN VACUMN (with other
info as well?) or EXPLAIN [VERBOSE] TABLE (see below).

In general EXPLAIN could be expanded to be a command to return an
explanation and stats of many items.
There could also be EXPLAIN that only shows fields and EXPLAIN VERBOSE
that also shows more detail such as stats (as that tends to take more
time to collect).

Examples:
EXPLAIN TABLE ttt show table fields and indexes/rules
VERBOSE:stats (inc tuple stats)
EXPLAIN INDEX iii show index description and stats
EXPLAIN USER/GROUP uuu show user name (and the users groups)
VERBOSE:list GRANTs
EXPLAIN FUNCTION/AGGREGATE/OPERATOR fff
show arguments of user functions
VERBOSE:show source code

These might be useful, easier to remember, unchanging between versions
alternatives to the SELECT * from pg_ttt methods used at present.
It it probably worth checking the security options for these (not every
user should have function source code access in some business apps).

>
> --
> Bruce Momjian | http://candle.pha.pa.us
> pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
> + If your life is a hard drive, | 830 Blythe Avenue
> + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

--
This is the identity that I use for NewsGroups. Email to
this will just sit there. If you wish to email me replace
the domain with knightpiesold . co . uk (no spaces).

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Niall Litchfield 2001-09-24 11:39:56 Re: NewYork Bombing: SQL server bomb proof!!
Previous Message Vince Vielhaber 2001-09-24 10:03:15 Re: Postgres Life of ...???

Browse pgsql-hackers by date

  From Date Subject
Next Message Niall Litchfield 2001-09-24 11:39:56 Re: NewYork Bombing: SQL server bomb proof!!
Previous Message Jean-Michel POURE 2001-09-24 08:53:31 Re: [HACKERS] UTF-8 support