On Mon, Jun 13, 2016 at 3:42 PM, Tom Lane <t...@sss.pgh.pa.us> wrote: >> I would not be surprised at a change to a parallel-query plan, but there's >> no parallelism here, so what happened? This looks like a bug to me. >> (Also, doing this query without COSTS OFF shows that the newly selected >> plan actually has a greater estimated cost than the expected plan, which >> makes it definitely a bug.) > > I looked into this and found that the costs are considered fuzzily the > same, and then add_path prefers the slightly-worse path on the grounds > that it is marked parallel_safe while the MinMaxAgg path is not. It seems > to me that there is some fuzzy thinking going on there. On exactly what > grounds is a path to be preferred merely because it is parallel safe, and > not actually parallelized?
A parallel-safe plan can be joined to a partial path at a higher level of the plan tree to form a new partial path. A non-parallel-safe path cannot. Therefore, if two paths are equally good, the one which is parallel-safe is more useful (just as a sorted path which is slightly more expensive than an unsorted path is worth keeping around because it is ordered). In practice, we don't yet have the ability for parallel-safe paths from subqueries to affect planning at higher query levels, but that's because the pathification stuff landed too late in the cycle for me to fully react to it. > Or perhaps the question to ask is whether a > MinMaxAgg path can be marked parallel-safe. That is a good question. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (email@example.com) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers