2 |
|
|
3 |
# count number of records in all tables |
# count number of records in all tables |
4 |
|
|
5 |
db="webpac-dev" |
if [ -z "$1" ] ; then |
6 |
|
db="webpac-dev" |
7 |
|
else |
8 |
|
db=$1 |
9 |
|
fi |
10 |
|
|
11 |
echo "records in $db, by table" |
echo "records in $db, by table" |
12 |
psql $db -A -t -F : -c "\d" | cut -d: -f2 | xargs -i psql $db -A -t -F " " -c "select count(*),'{}' from {}" | sort -nr |
psql $db -A -t -c "select tablename from pg_tables where tablename not like 'pg_%'" | xargs -i psql $db -A -t -F " " -c "select count(*),'{}' from {}" | sort -nr |