Re: [HACKERS] Account for cost and selectivity of HAVING quals - Mailing list pgsql-hackers

From Ashutosh Bapat
Subject Re: [HACKERS] Account for cost and selectivity of HAVING quals
Date
Msg-id CAFjFpRe_C8KfOGnKXz19PqwUFFY4=HrVz+12_G9-8TtZRaFikQ@mail.gmail.com
Whole thread Raw
In response to [HACKERS] Account for cost and selectivity of HAVING quals  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [HACKERS] Account for cost and selectivity of HAVING quals  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Wed, Nov 1, 2017 at 3:15 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Pursuant to the discussion at
> https://www.postgresql.org/message-id/20171029112420.8920B5FB05@mx.zeyos.com
> here's a patch to fix the planner so that eval costs and selectivity of
> HAVING quals are factored into the appropriate plan node numbers.
> Perhaps unsurprisingly, this doesn't change the results of any
> existing regression tests.
>
> It's slightly annoying that this approach will result in calculating
> the eval costs and selectivity several times, once for each aggregation
> plan type we consider.  I thought about inserting RestrictInfo nodes
> into the havingQual so that those numbers could be cached, but that turned
> out to break various code that doesn't expect to see such nodes there.
> I'm not sure it's worth going to the trouble of fixing that; in the big
> scheme of things, the redundant calculations likely don't cost much, since
> we aren't going to have relevant statistics.
>
> Comments?  If anyone wants to do a real review of this, I'm happy to stick
> it into the upcoming CF; but without an expression of interest, I'll just
> push it.  I don't think there's anything terribly controversial here.
>

I am not able to see how is the following hunk related to $subject
*************** create_result_path(PlannerInfo *root, Re
*** 1374,1379 ****
--- 1374,1380 ----     pathnode->path.startup_cost = target->cost.startup;     pathnode->path.total_cost =
target->cost.startup+         cpu_tuple_cost + target->cost.per_tuple;
 
+     /* Add cost of qual, if any --- but we ignore its selectivity */     if (resconstantqual)     {         QualCost
 qual_cost;
 

And may be we should try to explain why can we ignore selectivity.
Similarly for the changes in create_minmaxagg_path().

-- 
Best Wishes,
Ashutosh Bapat
EnterpriseDB Corporation
The Postgres Database Company


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

pgsql-hackers by date:

Previous
From: Michael Meskes
Date:
Subject: Re: [HACKERS] Try to fix endless loop in ecpg with informix mode
Next
From: Chris Travers
Date:
Subject: Re: [HACKERS] Oracle to PostGre