Re: verbose cost estimate

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Cc: Greg Stark <stark(at)mit(dot)edu>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: verbose cost estimate
Date: 2019-12-09 23:57:33
Message-ID: 20191209235733.GC2082@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 10, 2019 at 12:25:46AM +0100, Tomas Vondra wrote:
> >Everyone knows if you see a index scan is being used but is taking
> >longer than a sequential scan then you might try raising
> >random_page_cost. But I rarely see people tweaking the more "exotic"
> >parameters like operator_tuple_cost or index_tuple_cost and when they
> >do they aren't really sure what nodes they're affecting...
> >
>
> Well, but that's kinda my point - how would you know that you need to
> increase random_page_cost, or how big influence it has? The total is a
> fairly non-trivial combination of various cost parameters, effective
> cache size etc. Maybe I just don't understand how the cost is split into
> those pieces, named the same as the cost GUCs ...

Everything which right now does:
|cost += something*random_page_cost
..ends up (via a macro):
cost.random_page_cost += random_page_cost

And everything which does:
|cost1 += cost2
..ends up doing the same for each of the component members.

99% of this falls into place trivially.

I'm attaching a patch which is perhaps 95% working; various plans have changed,
so I gather there's at least a few bugs.

There's probably a few things which could be improved:
Probably some "Costs" should be simple doubles if they're only ever multiples
of a single cost parameter.
Maybe someone will say that Cost should be a typedef to a struct* rather than a struct.
Maybe I should get rid of cost_islt/isgt and just use cost_asscalar().
Seems like parallel_setup_cost and disable_cost could be booleans.

Justin

Attachment Content-Type Size
0001-Make-Cost-a-structure.patch text/x-diff 161.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2019-12-10 00:04:40 Re: xact_start for walsender & logical decoding not updated
Previous Message Tomas Vondra 2019-12-09 23:44:09 xact_start for walsender & logical decoding not updated