Re: Execution plans for tpc-h

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Victor Muntes Mutero <vmuntes(at)ac(dot)upc(dot)es>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Execution plans for tpc-h
Date: 2001-03-13 16:36:18
Message-ID: 19826.984501378@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Victor Muntes Mutero <vmuntes(at)ac(dot)upc(dot)es> writes:
> There is an xjoin (p_partkey = l_partkey)

Not in that form of the query. You have

WHERE ( ... ) OR ( ... ) OR ( ... )

If Postgres were to reduce the WHERE expression to CNF, it would discover
that the p_partkey = l_partkey clause is common to all three ORs,
whereupon it would have WHERE (p_partkey = l_partkey) AND (some big OR)
and could use p_partkey = l_partkey as a merge or hash join key.
But I suspect it decides that the WHERE is too complex to try to
simplify to CNF. We used to apply cnfify() unconditionally, but that
has some unpleasant exponential behavior on large expressions :-(.
What's worse is that DNF is actually the preferred form in some cases
--- especially when a repeated indexscan would be useful.

The heuristics that decide whether to convert to CNF could probably use
further refinement. If you are interested in playing with them, see
canonicalize_qual() in src/backend/optimizer/prep/prepqual.c. But it
would not be easy to recognize that this query would be better off in
CNF form: that requires noticing that the OR'd clauses have a lot of
terms in common, and you can't discover that without actually doing
most of the canonicalization work...

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-03-13 16:47:04 Re: "critical mass" reached?
Previous Message J.H.M. Dassen Ray 2001-03-13 16:05:13 Re: Backup and analyse