pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Consider fillfactor when estimating relation size
Date: Mon, 03 Jul 2023 17:52:15 +0000
Message-ID: <E1qGNih-001kCA-FN@gemulon.postgresql.org> (raw)

Consider fillfactor when estimating relation size

When table_block_relation_estimate_size() estimated the number of tuples
in a relation without statistics (e.g. right after load), it did not
consider fillfactor when calculating density. With non-default
fillfactor values, this may result in significant overestimate of the
number of tuples - up to 10x with the minimum 10% fillfactor. This may
have unexpected consequences, e.g. when creating hash indexes.

This considers the current fillfactor value in the "no statistics" code
path.  If the fillfactor changes after loading data into the table, the
estimate may be off. But that seems much less likely than changing the
fillfactor before the data load.

Reviewed-by: Corey Huinker, Peter Eisentraut
Discussion: https://postgr.es/m/cf154ef9-6bac-d268-b735-67a3443debba@enterprisedb.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/29cf61ade3f245aa40f427a1d6345287ef77e622

Modified Files
--------------
src/backend/access/table/tableam.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)



Message-ID: <E1qGNih-001kCA-FN@gemulon.postgresql.org>
Permalink:  ../E1qGNih-001kCA-FN@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1qGNih-001kCA-FN@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: tomas.vondra@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Consider fillfactor when estimating relation size
  In-Reply-To: <E1qGNih-001kCA-FN@gemulon.postgresql.org>

* 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