pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Wells Oliver <wells.oliver@gmail.com>
Cc: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Re: explaining the pg_total_relation_size/pg_relation_size results
Date: Wed, 20 Jun 2018 18:42:03 -0400
Message-ID: <20180620224203.fqlzl2d3dhvcbe7q@alvherre.pgsql> (raw)
In-Reply-To: <CAOC+FBWk93oR6qj-iqi1EyZdzNGUQ=Vyxdz9ttGs0r=R1kYGMA@mail.gmail.com>

On 2018-Jun-20, Wells Oliver wrote:

> I have the follwing in a view to glance at the size of my relations:
> 
> pg_size_pretty(pg_relation_size(c.oid::regclass)) AS size,
> pg_total_relation_size(c.oid::regclass) AS bytes
> 
> This view sorts by pg_relation_size(c.oid::regclass) descending.
> 
> The question is: the byte values are often higher for relations with a
> lower size indicated by size. As I sit here, I see an 11GB table
> of 23821893632 bytes and a 12GB table of 14545387520 bytes, and
> lastly/weirdly, a 3194MB table of 19924844544 bytes.

This is a strange question.  pg_total_relation_size includes the size of
indexes and toast table and index, which pg_relation_size does not, so
it seems natural that they give wildly different results for differently
shaped tables.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




view thread (3+ messages)  latest in thread

Message-ID: <20180620224203.fqlzl2d3dhvcbe7q@alvherre.pgsql>
Permalink:  ../20180620224203.fqlzl2d3dhvcbe7q@alvherre.pgsql/
Also on:    postgresql.org/message-id/20180620224203.fqlzl2d3dhvcbe7q@alvherre.pgsql

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: alvherre@2ndquadrant.com, wells.oliver@gmail.com
  Subject: Re: explaining the pg_total_relation_size/pg_relation_size results
  In-Reply-To: <20180620224203.fqlzl2d3dhvcbe7q@alvherre.pgsql>

* 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