Re: Accounting for metapages in genericcostestimate()

2025-04-30 Thread Tom Lane
=?utf-8?Q?=C3=81lvaro?= Herrera writes: > On 2025-Apr-28, Tom Lane wrote: >> +BlockNumber numNonLeafPages;/* # of index pages that are not leafs >> */ > I find the use of "leafs" as plural for "leaf" a bit strange ... > We already have uses of that word, but I wonder if they don't mostly

Re: Accounting for metapages in genericcostestimate()

2025-04-30 Thread Álvaro Herrera
On 2025-Apr-28, Tom Lane wrote: > @@ -135,6 +141,7 @@ typedef struct > double numIndexTuples; /* number of leaf tuples visited */ > double spc_random_page_cost; /* relevant random_page_cost > value */ > double num_sa_scans; /* # indexscans from Sca

Re: Accounting for metapages in genericcostestimate()

2025-04-28 Thread Tom Lane
... sigh, this time with the patch actually attached. regards, tom lane diff --git a/contrib/bloom/blcost.c b/contrib/bloom/blcost.c index a38fcf3c579..4359b81d196 100644 --- a/contrib/bloom/blcost.c +++ b/contrib/bloom/blcost.c @@ -30,6 +30,9 @@ blcostestimate(PlannerInfo

Accounting for metapages in genericcostestimate()

2025-04-28 Thread Tom Lane
Per the discussion at [1], genericcostestimate() produces estimates that are noticeably off for small indexes, because it fails to discount the index metapage while computing numIndexPages. Here's a first-draft attempt at improving that. The basic issue is that the calculation of numIndexPages is