Thread: Disk usage

Disk usage

From
Daniel Lublin
Date:
Good day.

I am wondering if there is some utility for postgresql, which can
display the amount of disk space that a database (and possibly even
more finer grained; a table) occupies?

I could probably examine $PGDATA/base, but then I'd first have to
figure out how things are stored in there. So assumed there already
would be some utility that does this.

//Daniel


Re: Disk usage

From
"Shridhar Daithankar"
Date:
On 8 May 2003 at 12:41, Daniel Lublin wrote:

>
> Good day.
>
> I am wondering if there is some utility for postgresql, which can
> display the amount of disk space that a database (and possibly even
> more finer grained; a table) occupies?

du in $PGDATA coupled with oid2name to figure out what is the object you are
lookng at.

HTH

Bye
 Shridhar

--
Famous last words:    (1) "Don't worry, I can handle it."    (2) "You and what army?"
(3) "If you were as smart as you think you are, you wouldn't be         a cop."


Re: Disk usage

From
Tom Lane
Date:
"Shridhar Daithankar" <shridhar_daithankar@persistent.co.in> writes:
> On 8 May 2003 at 12:41, Daniel Lublin wrote:
>> I am wondering if there is some utility for postgresql, which can
>> display the amount of disk space that a database (and possibly even
>> more finer grained; a table) occupies?

> du in $PGDATA coupled with oid2name to figure out what is the object you are
> lookng at.

Or do

    vacuum;
    select relname, relpages * 8 from pg_class;

to get table sizes in kilobytes.  relpages is not updated on-the-fly,
only by vacuum, so you need to have done vacuum recently to get
trustworthy numbers.

            regards, tom lane


Re: Disk usage

From
"Jay O'Connor"
Date:
On 2003.05.08 04:12 Shridhar Daithankar wrote:
> On 8 May 2003 at 12:41, Daniel Lublin wrote:
>
> >
> > Good day.
> >
> > I am wondering if there is some utility for postgresql, which can
> > display the amount of disk space that a database (and possibly even
> > more finer grained; a table) occupies?
>
> du in $PGDATA coupled with oid2name to figure out what is the object you
> are
> lookng at.
>
> HTH
>

Thanks, I found that helpful.

One question though is about the transaction log files on the px_log
directory I have two huge files totalling about 30 meg. One thing I'm
working on is figuring out how much disk usage I'll have for our data
compared to what we are using now.  I'm wondering if I should count those
two files and if there is a way of eliminating them if they ever become not
needed

Thanks

Take care,
Jay

Re: Disk usage

From
"scott.marlowe"
Date:
On Thu, 8 May 2003, Jay O'Connor wrote:

> On 2003.05.08 04:12 Shridhar Daithankar wrote:
> > On 8 May 2003 at 12:41, Daniel Lublin wrote:
> >
> > >
> > > Good day.
> > >
> > > I am wondering if there is some utility for postgresql, which can
> > > display the amount of disk space that a database (and possibly even
> > > more finer grained; a table) occupies?
> >
> > du in $PGDATA coupled with oid2name to figure out what is the object you
> > are
> > lookng at.
> >
> > HTH
> >
>
> Thanks, I found that helpful.
>
> One question though is about the transaction log files on the px_log
> directory I have two huge files totalling about 30 meg. One thing I'm
> working on is figuring out how much disk usage I'll have for our data
> compared to what we are using now.  I'm wondering if I should count those
> two files and if there is a way of eliminating them if they ever become not
> needed

That's the write ahead logging system.  It isn't optional, so it won't
ever not be needed.  But, you can change how big they are by playing with
the WAL settings in the $PGDATA/postgresql.conf file.

http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=runtime-config.html#RUNTIME-CONFIG-WAL


Re: Disk usage

From
Alvaro Herrera
Date:
On Thu, May 08, 2003 at 10:39:48AM -0400, Tom Lane wrote:

> Or do
>
>     vacuum;
>     select relname, relpages * 8 from pg_class;
>
> to get table sizes in kilobytes.  relpages is not updated on-the-fly,
> only by vacuum, so you need to have done vacuum recently to get
> trustworthy numbers.

Doesn't ANALYZE update relpages values?

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"God is real, unless declared as int"


Re: Disk usage

From
Bruce Momjian
Date:
Alvaro Herrera wrote:
> On Thu, May 08, 2003 at 10:39:48AM -0400, Tom Lane wrote:
>
> > Or do
> >
> >     vacuum;
> >     select relname, relpages * 8 from pg_class;
> >
> > to get table sizes in kilobytes.  relpages is not updated on-the-fly,
> > only by vacuum, so you need to have done vacuum recently to get
> > trustworthy numbers.
>
> Doesn't ANALYZE update relpages values?

Yes, vacuum and analyze do it.  There is a 'monitoring disk space'
section in the 7.3 docs too.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073