Re: Should heapam_estimate_rel_size consider fillfactor? - Mailing list pgsql-hackers

From Tomas Vondra
Subject Re: Should heapam_estimate_rel_size consider fillfactor?
Date
Msg-id 2146d2f2-b445-3669-e231-4a2407f5bb9c@enterprisedb.com
Whole thread Raw
In response to Re: Should heapam_estimate_rel_size consider fillfactor?  (Tomas Vondra <tomas.vondra@enterprisedb.com>)
List pgsql-hackers
On 7/3/23 11:40, Tomas Vondra wrote:
> ...
>
> FWIW the reason why the integer division is intentional is most likely
> that we want "floor" semantics - if there's 10.23 rows per page, that
> really means 10 rows per page.
> 
> I doubt it makes a huge difference in this particular place, considering
> we're calculating the estimate from somewhat unreliable values, and then
> use it for rough estimate of relation size.
> 
> But from this POV, I think it's more correct to do it "my" way:
> 
>   density = (usable_bytes_per_page * fillfactor / 100) / tuple_width;
> 
> because that's doing *two* separate integer divisions, with floor
> semantics. First we calculate "usable bytes" (rounded down), then
> average number of rows per page (also rounded down).
> 
> Corey's formula would do just one integer division. I don't think it
> makes a huge difference, though. I mean, it's just an estimate and so we
> can't expect to be 100% accurate.
> 

Pushed, using the formula with two divisions (as in the original patch).

regards

-- 
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Álvaro Herrera
Date:
Subject: Re: Does a cancelled REINDEX CONCURRENTLY need to be messy?
Next
From: "Tristan Partin"
Date:
Subject: Re: Optionally using a better backtrace library?