Unix Technical Forum

How do I measure user disk usage on Postgresql table?

This is a discussion on How do I measure user disk usage on Postgresql table? within the Pgsql General forums, part of the PostgreSQL category; --> Lets say I have a Postgresql table where I store uploaded data for all users, identified by user_id column. ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 04:09 PM
Dave
 
Posts: n/a
Default How do I measure user disk usage on Postgresql table?

Lets say I have a Postgresql table where I store uploaded data for all users, identified by user_id column. Is it possible to run a query to measure the storage a user is consuming?

Ideally this would be a SELECT query with WHERE clause on user_id and will only return size of the data field(s), rather then the overhead.

Any other ideas?

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 06:20 AM
Richard Huxton
 
Posts: n/a
Default Re: How do I measure user disk usage on Postgresql table?

Dave wrote:
> Lets say I have a Postgresql table where I store uploaded data for
> all users, identified by user_id column. Is it possible to run a
> query to measure the storage a user is consuming?


Not really. You could get the size of the whole table with
pg_relation_size() and then estimate a user's share by seeing what % of
rows have their user-id.

If it's the sort of thing you'll be checking constantly, then I'd keep a
summary table up-to-date using triggers instead.

Oh - if you're going to be asking questions regularly then you'll
probably get more answers if you have a valid email address.

--
Richard Huxton
Archonet Ltd

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-19-2008, 06:20 AM
Dave
 
Posts: n/a
Default Re: How do I measure user disk usage on Postgresql table?

"Richard Huxton" <dev@archonet.com> wrote in message
news:4808991E.7060501@archonet.com...
> Dave wrote:
>> Lets say I have a Postgresql table where I store uploaded data for
>> all users, identified by user_id column. Is it possible to run a
>> query to measure the storage a user is consuming?

>
> Not really. You could get the size of the whole table with
> pg_relation_size() and then estimate a user's share by seeing what % of
> rows have their user-id.
>
> If it's the sort of thing you'll be checking constantly, then I'd keep a
> summary table up-to-date using triggers instead.
>
> Oh - if you're going to be asking questions regularly then you'll probably
> get more answers if you have a valid email address.
>
> --
> Richard Huxton
> Archonet Ltd
>
> --

Richard,

Thanks for the answer.

So what is the proper way of managing user quota on database (apart from
having separate table for each)?

> Oh - if you're going to be asking questions regularly then you'll probably
> get more answers if you have a valid email address.

Isn't that asking for spam (and I know the answer to that)? Why would it
matter for someone to answer my post based on my email address, if the
discussion is going over the groups? One might just as well use:
fake_user@gmail.com. At least I'm forthcoming by making it obvious that my
email address is not real. Just a thought.





Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:03 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com