Re: size of table + toasted tables + indexes != pg_total_relation_size - Mailing list pgsql-admin

From Andrew Gierth
Subject Re: size of table + toasted tables + indexes != pg_total_relation_size
Date
Msg-id 87d0rk3itx.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to Re: size of table + toasted tables + indexes != pg_total_relation_size  (Mariel Cherkassky <mariel.cherkassky@gmail.com>)
List pgsql-admin
>>>>> "Mariel" == Mariel Cherkassky <mariel.cherkassky@gmail.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)


pgsql-admin by date:

Previous
From: Mariel Cherkassky
Date:
Subject: Re: size of table + toasted tables + indexes != pg_total_relation_size
Next
From: Rui DeSousa
Date:
Subject: Re: size of table + toasted tables + indexes !=pg_total_relation_size