Re: vacuum verbose relations reporting

Поиск
Список
Период
Сортировка
От Jeff Frost
Тема Re: vacuum verbose relations reporting
Дата
Msg-id 48B4EDF7.9080505@frostconsultingllc.com
обсуждение исходный текст
Ответ на Re: vacuum verbose relations reporting  (Alvaro Herrera <alvherre@commandprompt.com>)
Ответы Re: vacuum verbose relations reporting
Список pgsql-admin
Alvaro Herrera wrote:
Jeff Frost wrote:
 
Tom, is there an easy (or hard) way to count relations from all DBs by 
using the system catalogs?   
Just do a count(*) from pg_class where relkind in ('r', 't', 'i'), and
sum across all databases (you need to connect to each one).

(Actually you only need to count indexes that are btrees, if you need
such a distinction.  Other indexes do not use the FSM as far as I know). 
Perfect, so here's a little script that does the trick then:

#!/bin/sh

PSQL=/usr/bin/psql
DATABASES=$($PSQL -lt |  awk {'print $1'} | grep -v template0 )
RELATIONS=0

for DB in $DATABASES; do
    RELATIONS=$(($RELATIONS + $($PSQL --tuples-only --command "select count(*) from pg_class where relkind IN ('r', 't', 'i');" $DB) ))
done

echo $RELATIONS

Thanks folks!

-- 
Jeff Frost, Owner 	<jeff@frostconsultingllc.com>
Frost Consulting, LLC 	http://www.frostconsultingllc.com/
Phone: 916-647-6411	FAX: 916-405-4032

В списке pgsql-admin по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: vacuum verbose relations reporting
Следующее
От: "Merlin Moncure"
Дата:
Сообщение: Re: [GENERAL] PITR - base backup question