Skip to content

Commit 9888192

Browse files
committed
Instead of trying to force WHERE clauses into CNF or DNF normal form,
just look for common clauses that can be pulled out of ORs. Per recent discussion, extracting common clauses seems to be the only really useful effect of normalization, and if we do it explicitly then we can avoid cluttering the qual with partially-redundant duplicated expressions, which was an unpleasant side-effect of the old approach.
1 parent 7af16b2 commit 9888192

File tree

2 files changed

+180
-530
lines changed

2 files changed

+180
-530
lines changed

src/backend/optimizer/README

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,11 @@ planner()
200200
do final cleanup after planning.
201201
-subquery_planner()
202202
pull up subqueries from rangetable, if possible
203-
simplify constant expressions
204203
canonicalize qual
205-
Attempt to reduce WHERE clause to either CNF or DNF canonical form.
206-
CNF (top-level-AND) is preferred, since the optimizer can then use
207-
any of the AND subclauses to filter tuples; but quals that are in
208-
or close to DNF form will suffer exponential expansion if we try to
209-
force them to CNF. In pathological cases either transform may expand
210-
the qual unreasonably; so we may have to leave it un-normalized,
211-
thereby reducing the accuracy of selectivity estimates.
204+
Attempt to simplify WHERE clause to the most useful form; this includes
205+
flattening nested AND/ORs and detecting clauses that are duplicated in
206+
different branches of an OR.
207+
simplify constant expressions
212208
process sublinks
213209
convert Vars of outer query levels into Params
214210
--grouping_planner()

0 commit comments

Comments
 (0)