Re: BRIN cost estimate

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <david.rowley@2ndquadrant.com>
Cc: Emre Hasegeli <emre@hasegeli.com>, Alvaro Herrera <alvherre@2ndquadrant.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2017-04-06T15:47:55Z
Lists: pgsql-hackers
David Rowley <david.rowley@2ndquadrant.com> writes:
> + *indexTotalCost += 0.1 * cpu_operator_cost * estimatedRanges *
> + pagesPerRange;

> This is trying to cost up the following code in bringetbitmap()

> if (addrange)
> {
> BlockNumber pageno;

> for (pageno = heapBlk;
> pageno <= heapBlk + opaque->bo_pagesPerRange - 1;
> pageno++)
> {
> MemoryContextSwitchTo(oldcxt);
> tbm_add_page(tbm, pageno);
> totalpages++;
> MemoryContextSwitchTo(perRangeCxt);
> }

> I'm charging 0.1 * cpu_operator_cost for each loop we expect to
> perform here.

TBH, I think that code is in the noise.  It doesn't involve any disk
access, or catalog access, or user-defined function calls.  I wouldn't
bother trying to account for it.

What you should be accounting for is the ensuing heap page accesses,
but I assume that's done somewhere else.

			regards, tom lane


Commits

  1. Fix BRIN cost estimation

  2. Make use of statistics on index expressions. There are still some