/[scripts]/trunk/pg_size
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/pg_size

Parent Directory Parent Directory | Revision Log Revision Log


Revision 79 - (show annotations)
Wed May 14 16:28:17 2008 UTC (14 years, 8 months ago) by dpavlin
File size: 711 byte(s)
added number of tuples to output of single database as last number

1 #!/bin/sh
2
3 if [ "$1" == "-u" ] ; then
4 psql -A -l -t | grep -v template0 | awk -F'|' '{print $1}' | xargs -i psql -t -A -F" " -c "select sum(pg_relation_size(pg_class.oid)), '{}', pg_user.usename from pg_class inner join pg_user on pg_user.usesysid=pg_class.relowner group by pg_user.usename order by sum(pg_class.relpages) desc limit 1" {} | sort -k1,1 -n -r
5 elif [ ! -z "$1" ] ; then
6 psql -t -A -F" " -c "select pg_relation_size(oid) as size,relname,reltuples from pg_class where relkind = 'r' and relname not like 'pg_%' order by size desc" $1
7 else
8 psql -A -l -t -F: | grep -v template0 | cut -d: -f1 | xargs -i psql -t -A -F" " -c "select sum(pg_relation_size(oid)),'{}' from pg_class" {} | sort -r -n
9 fi

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26