From: | Stephen Frost <sfrost(at)snowman(dot)net> |
---|---|
To: | Andreas Joseph Krogh <andreas(at)visena(dot)com> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Sv: Re: Sv: Re: Does PostgreSQL check database integrity at startup? |
Date: | 2017-12-31 01:03:15 |
Message-ID: | 20171231010315.GN2416@tamriel.snowman.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Greetings Andreas,
* Andreas Joseph Krogh (andreas(at)visena(dot)com) wrote:
> Here's a simple test-case:
>
> createdb test
> test=# create table foo(id serial primary key, name varchar not null);
> test=# CREATE TYPE BigIntTuple2 AS (f1 bigint, f2 bigint);
Hah, appears we allocate a relfilenode to types too, though it's not
entirely clear to me why (evidently, they're not used..).
Anyhow, adding a filter on relkind addresses it (though it's not very
future-proof, unfortunately):
SELECT
quote_ident(nsp.nspname) || '.' || quote_ident(c.relname),
s.setting || '/base/' || db.oid || '/' || c.relfilenode,
(pg_stat_file(s.setting || '/base/' || db.oid || '/' || c.relfilenode)).size as size
FROM
pg_settings s
JOIN pg_database db on (s.name = 'data_directory')
JOIN pg_class c on (datname = current_database())
JOIN pg_namespace nsp on (c.relnamespace = nsp.oid)
WHERE
relfilenode <> 0
AND nsp.nspname !~ '^pg_'
AND nsp.nspname <> 'information_schema'
AND c.relkind in ('r','i','m','p');
Thanks!
Stephen
From | Date | Subject | |
---|---|---|---|
Next Message | Jan Wieck | 2017-12-31 03:10:59 | Re: Does PostgreSQL check database integrity at startup? |
Previous Message | Andreas Joseph Krogh | 2017-12-31 00:27:41 | Sv: Re: Sv: Re: Does PostgreSQL check database integrity at startup? |