Re: size of table + toasted tables + indexes != pg_total_relation_size

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Mariel Cherkassky <mariel(dot)cherkassky(at)gmail(dot)com>
Cc: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: size of table + toasted tables + indexes != pg_total_relation_size
Date: 2018-11-04 16:47:06
Message-ID: 87d0rk3itx.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

>>>>> "Mariel" == Mariel Cherkassky <mariel(dot)cherkassky(at)gmail(dot)com> writes:

>> You should probably check whether there are files in the db's
>> directory that do not correspond to the filenode of any table (use
>> select pg_relation_filenode(oid) from pg_class; to get a list of
>> filenodes)

Mariel> * and If i'll find some, is it safe just to delete them ?*

You need to check that they're not recent (i.e. could not belong to
table creations/rewrites that are still in progress, since those would
not be visible in pg_class).

Also make sure you're looking in the right database (using
pg_relation_filepath instead may make this clearer).

Remember that a given filenode/filepath also generates names with
suffixes for forks (e.g. _vm) and segments (.1, .2 etc) - those need to
be kept for valid filenodes and deleted along with orphaned ones.

Naturally, if you get this wrong you will break your database beyond
easy recovery, so BE CAREFUL. As an extra check, you could look at the
times of the files and check against your server logs to see if there
were indeed any crashes or unclean restarts of pg around those times; if
you have a lot of apparently orphaned files you should investigate why.

--
Andrew (irc:RhodiumToad)

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Rui DeSousa 2018-11-04 19:49:57 Re: size of table + toasted tables + indexes != pg_total_relation_size
Previous Message Mariel Cherkassky 2018-11-04 15:09:20 Re: size of table + toasted tables + indexes != pg_total_relation_size