brown-bag-bug-fix: writing MARC file just once (at end) will save a lot of time
[webpac] / tools / count_tables.sh
index 7c80b5b..29f7168 100755 (executable)
@@ -2,7 +2,11 @@
 
 # count number of records in all tables
 
-db="webpac-dev"
+if [ -z "$1" ] ; then
+       db="webpac-dev"
+else
+       db=$1
+fi
 
 echo "records in $db, by table"
-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