Re: pg_stats.avg_width

From: Maciek Sakrejda <m(dot)sakrejda(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: pg_stats.avg_width
Date: 2023-05-19 06:33:11
Message-ID: CAOtHd0AGRN6_P8a9oiyudGE5ATOSsvzm6ftpekkPuUuF0hQmuA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks, that makes sense. It was going to be my third guess, but it
seemed pretty wide for a TOAST pointer. Reviewing what goes in there,
though, it's reasonable.

I assume that this means for unTOASTed but compressed data, this
counts the compressed size.

Would a doc patch clarifying this (and possibly linking to the
relevant TOAST docs [1]) be welcome? The current wording is pretty
vague. Something like

diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index 7c09ab3000..2814ac8007 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -7466,7 +7466,9 @@ SCRAM-SHA-256$<replaceable>&lt;iteration
count&gt;</replaceable>:<replaceable>&l
<structfield>stawidth</structfield> <type>int4</type>
</para>
<para>
- The average stored width, in bytes, of nonnull entries
+ The average stored width, in bytes, of nonnull entries. For compressed
+ entries, counts the compressed size; for TOASTed data, the size of the
+ TOAST pointer (see <link linkend="storage-toast">TOAST</link>).
</para></entry>
</row>

diff --git a/doc/src/sgml/system-views.sgml b/doc/src/sgml/system-views.sgml
index bb1a418450..62184fe32b 100644
--- a/doc/src/sgml/system-views.sgml
+++ b/doc/src/sgml/system-views.sgml
@@ -3680,7 +3680,9 @@ SELECT * FROM pg_locks pl LEFT JOIN pg_prepared_xacts ppx
<structfield>avg_width</structfield> <type>int4</type>
</para>
<para>
- Average width in bytes of column's entries
+ Average width in bytes of column's entries. For compressed entries,
+ counts the compressed size; for TOASTed data, the size of the TOAST
+ pointer (see <link linkend="storage-toast">TOAST</link>).
</para></entry>
</row>

(not sure if this should be <link /> or <xref />).

Thanks,
Maciek

[1]: https://www.postgresql.org/docs/current/storage-toast.html

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Raymond Brinzer 2023-05-19 06:48:10 Re: Records, Types, and Arrays
Previous Message Raymond Brinzer 2023-05-19 06:16:58 Re: Records, Types, and Arrays