Hi, I thought it would be nice to give the user a better idea of what avg_leaf_density and leaf_fragmentation mean.

Patch attached. What do you think?
From 5c82c207776fb8cde2357081b8579ba6db195c06 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Yhuel?= <frederic.yh...@dalibo.com>
Date: Tue, 5 Nov 2024 17:59:44 +0100
Subject: [PATCH] doc: explain pgstatindex fragmentation

It was quite hard to guess what leaf_fragmentation meant without looking
at pgstattuple's code. This patch aims to give to the user a better
idea of what it means.
---
 doc/src/sgml/pgstattuple.sgml | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/doc/src/sgml/pgstattuple.sgml b/doc/src/sgml/pgstattuple.sgml
index 4071da4ed9..8908b56663 100644
--- a/doc/src/sgml/pgstattuple.sgml
+++ b/doc/src/sgml/pgstattuple.sgml
@@ -277,6 +277,14 @@ leaf_fragmentation | 0
      page-by-page, and should not be expected to represent an
      instantaneous snapshot of the whole index.
     </para>
+
+    <para>
+     <literal>avg_leaf_density</literal> can be seen as the inverse of bloat,
+     while <literal>leaf_fragmentation</literal> represents a measure of disorder.
+     The higher <literal>leaf_fragmentation</literal> is, the less the physical
+     order of the index leaf pages corresponds to the logical order we would have
+     just after a <command>REINDEX</command>.
+    </para>
     </listitem>
    </varlistentry>
 
-- 
2.39.5

Reply via email to