Re: pg_total_relation_size accuracy guarantee

From: Nikita <jne100(at)gmail(dot)com>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: pg_total_relation_size accuracy guarantee
Date: 2017-11-24 10:52:19
Message-ID: CAMCZdezp-SFmk__=soezc3Qu7m_YHEJMNxuaykHU_wY6P4GOYQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Source is good enough in my case and I planned to grep it anyway, so thanks
for saving my time!

2017-11-24 10:15 GMT+03:00 Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>:

> 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
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Oleg Bartunov 2017-11-24 11:19:38 Re: update field in jsonb
Previous Message Laurenz Albe 2017-11-24 07:15:01 Re: pg_total_relation_size accuracy guarantee