Re: Finding the size of your biggest relations - Mailing list pgsql-admin

From Tom Lane
Subject Re: Finding the size of your biggest relations
Date
Msg-id 13514.1474641052@sss.pgh.pa.us
Whole thread Raw
In response to Re: Finding the size of your biggest relations  (Artem Tomyuk <admin@leboutique.com>)
List pgsql-admin
Artem Tomyuk <admin@leboutique.com> writes:
> Sorry,
> this query

> SELECT nspname || '.' || relname AS "relation",
>     pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size"
>   FROM pg_class C
>   LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
>   WHERE nspname NOT IN ('pg_catalog', 'information_schema')
>     AND C.relkind <> 'i'
>     AND nspname !~ '^pg_toast'
>   ORDER BY pg_total_relation_size(C.oid) DESC
>   LIMIT 20;

I think what's happening is that your ORDER BY is sorting nulls first.
So what's coming out at the top is temp relations that were dropped
between the time of the statement snapshot and the time that
pg_total_relation_size looked at them.  Try ORDER BY ... DESC NULLS LAST.

            regards, tom lane


pgsql-admin by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: does cluster created through initdb update postgres-reg.ini with its entry?
Next
From: Richard Albright
Date:
Subject: PL/Python using anaconda