postgresql/src/backend/optimizer/util
Tom Lane 7b6c075471 Teach planner to account for HAVING quals in aggregation plan nodes.
For some reason, we have never accounted for either the evaluation cost
or the selectivity of filter conditions attached to Agg and Group nodes
(which, in practice, are always conditions from a HAVING clause).

Applying our regular selectivity logic to post-grouping conditions is a
bit bogus, but it's surely better than taking the selectivity as 1.0.
Perhaps someday the extended-statistics mechanism can be taught to provide
statistics that would help us in getting non-default estimates here.

Per a gripe from Benjamin Coutu.  This is surely a bug fix, but I'm
hesitant to back-patch because of the prospect of destabilizing existing
plan choices.  Given that it took us this long to notice the bug, it's
probably not hurting too many people in the field.

Discussion: https://postgr.es/m/20968.1509486337@sss.pgh.pa.us
2017-11-02 11:24:12 -04:00
..
Makefile Extract restriction OR clauses whether or not they are indexable. 2013-12-30 12:24:37 -05:00
clauses.c Allow parallel query for prepared statements with generic plans. 2017-10-27 22:22:39 +02:00
joininfo.c Fix typos in comments. 2017-02-06 11:33:58 +02:00
orclauses.c Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
pathnode.c Teach planner to account for HAVING quals in aggregation plan nodes. 2017-11-02 11:24:12 -04:00
placeholder.c Basic partition-wise join functionality. 2017-10-06 11:11:10 -04:00
plancat.c Copy information from the relcache instead of pointing to it. 2017-10-06 15:28:07 -04:00
predtest.c Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
relnode.c Basic partition-wise join functionality. 2017-10-06 11:11:10 -04:00
restrictinfo.c Avoid out-of-memory in a hash join with many duplicate inner keys. 2017-08-15 14:05:53 -04:00
tlist.c Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
var.c Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00