From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jehan-Guillaume de Rorthais <ioguix@free.fr>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Strange avg value size for index on expression in pg_stats
Date: Mon, 10 Nov 2014 09:39:23 -0500
Message-ID: <24416.1415630363@sss.pgh.pa.us> (raw)
In-Reply-To: <20141110115254.2997aaf8@erg>
References: <20141110115254.2997aaf8@erg>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>
Jehan-Guillaume de Rorthais <ioguix@free.fr> writes:
> While investigating about a wrong result with my btree bloat estimation query,
> I found a strange stat deviation between the average size of a value in its
> table and its average size in one index on the "lower" expression.
ANALYZE doesn't look at the physical index at all. For an expression
index, it will recompute the index expression at each sampled row, and
then take statistics on those values. In the case you've got here, it's
re-running the lower() function and looking at the uncompressed result.
So that accounts for the discrepancy in average width stats.
> This tiny difference is the source of a very bad estimation with the
> Btree bloat estimation query when values are around an alignement
> boundary.
TBH, if that query is relying on ANALYZE width estimates to be accurate
to the last byte, its reliability is going to be horrid anyway.
regards, tom lane
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
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-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, ioguix@free.fr
Subject: Re: Strange avg value size for index on expression in pg_stats
In-Reply-To: <24416.1415630363@sss.pgh.pa.us>
* 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