Account for cost and selectivity of HAVING quals

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Account for cost and selectivity of HAVING quals
Date: 2017-10-31 21:45:37
Message-ID: 20968.1509486337@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

regards, tom lane

Attachment Content-Type Size
account-for-HAVING-properly-1.patch text/x-diff 7.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rob McColl 2017-10-31 22:14:04 Re: PostgreSQL 10 parenthesized single-column updates can produce errors
Previous Message srielau 2017-10-31 21:28:37 Re: proposal: schema variables