Re: Sv: Re: Sv: Re: Does PostgreSQL check database integrity atstartup? - Mailing list pgsql-general

From Stephen Frost
Subject Re: Sv: Re: Sv: Re: Does PostgreSQL check database integrity atstartup?
Date
Msg-id 20171231010315.GN2416@tamriel.snowman.net
Whole thread Raw
In response to Sv: Re: Sv: Re: Does PostgreSQL check database integrity at startup?  (Andreas Joseph Krogh <andreas@visena.com>)
List pgsql-general
Greetings Andreas,

* Andreas Joseph Krogh (andreas@visena.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

Attachment

pgsql-general by date:

Previous
From: Andreas Joseph Krogh
Date:
Subject: Sv: Re: Sv: Re: Does PostgreSQL check database integrity at startup?
Next
From: Jan Wieck
Date:
Subject: Re: Does PostgreSQL check database integrity at startup?