pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Nikita <jne100@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: pg_total_relation_size accuracy guarantee
Date: Fri, 24 Nov 2017 08:15:01 +0100
Message-ID: <1511507701.2469.5.camel@cybertec.at> (raw)
In-Reply-To: <CAMCZdexsp1Y5y3wZ5HqGvie3aYN54Bfy95Yyz2RrLZYy=CrrUA@mail.gmail.com>
References: <CAMCZdexsp1Y5y3wZ5HqGvie3aYN54Bfy95Yyz2RrLZYy=CrrUA@mail.gmail.com>

Nikita wrote:
> 1. pg_total_relation_size return predictable approximately correct table size (apart from some preallocation) without subsequent VACUUM/ANALYZE/anything call as long as I don't DELETE/UPDATE rows;
>  
> 2. DROP/TRUNCATE table reclaim disc space without subsequent VACUUM;
>  
> These assumptions are correct? Is it fixed in doc if so?

Sort of, if you consider the source as documentation.

Ad pg_total_relation_size:

See the function definition in backend/utils/adt/dbsize.c and
the functions that it calls, especially "calculate_relation_size":

PostgreSQL uses the stat(2) system call to determine the actual
size of the files on disk.

Ad TRUNCATE (from backend/commands/tablecmds.c):

  /*
   * Need the full transaction-safe pushups.
   *
   * Create a new empty storage file for the relation, and assign it
   * as the relfilenode value. The old storage file is scheduled for
   * deletion at commit.
   */

Yours,
Laurenz Albe




view thread (3+ messages)  latest in thread

Message-ID: <1511507701.2469.5.camel@cybertec.at>
Permalink:  ../1511507701.2469.5.camel@cybertec.at/
Also on:    postgresql.org/message-id/1511507701.2469.5.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: laurenz.albe@cybertec.at, jne100@gmail.com
  Subject: Re: pg_total_relation_size accuracy guarantee
  In-Reply-To: <1511507701.2469.5.camel@cybertec.at>
  References: <CAMCZdexsp1Y5y3wZ5HqGvie3aYN54Bfy95Yyz2RrLZYy=CrrUA@mail.gmail.com> <1511507701.2469.5.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox