Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bCXmZ-0003p9-6i for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Jun 2016 19:44:23 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bCXmY-00011T-Gh for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Jun 2016 19:44:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bCXlD-0007yg-9z for pgsql-hackers@postgresql.org; Mon, 13 Jun 2016 19:42:59 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bCXl9-0006Me-7s for pgsql-hackers@postgresql.org; Mon, 13 Jun 2016 19:42:57 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u5DJgnYh001598; Mon, 13 Jun 2016 15:42:49 -0400 From: Tom Lane To: Robert Haas cc: Amit Kapila , David Rowley , Thomas Munro , Pg Hackers Subject: Re: ERROR: ORDER/GROUP BY expression not found in targetlist In-reply-to: <20756.1465834072@sss.pgh.pa.us> References: <15695.1465827695@sss.pgh.pa.us> <17170.1465830165@sss.pgh.pa.us> <20756.1465834072@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 13 Jun 2016 12:07:52 -0400" Date: Mon, 13 Jun 2016 15:42:49 -0400 Message-ID: <1597.1465846969@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org I wrote: > ... there was also an unexplainable plan change: > *** /home/postgres/pgsql/src/test/regress/expected/aggregates.out Thu Apr 7 21:13:14 2016 > --- /home/postgres/pgsql/src/test/regress/results/aggregates.out Mon Jun 13 11:54:01 2016 > *************** > *** 577,590 **** > explain (costs off) > select max(unique1) from tenk1 where unique1 > 42000; > ! QUERY PLAN > ! --------------------------------------------------------------------------- > ! Result > ! InitPlan 1 (returns $0) > ! -> Limit > ! -> Index Only Scan Backward using tenk1_unique1 on tenk1 > ! Index Cond: ((unique1 IS NOT NULL) AND (unique1 > 42000)) > ! (5 rows) > select max(unique1) from tenk1 where unique1 > 42000; > max > --- 577,588 ---- > explain (costs off) > select max(unique1) from tenk1 where unique1 > 42000; > ! QUERY PLAN > ! ---------------------------------------------------- > ! Aggregate > ! -> Index Only Scan using tenk1_unique1 on tenk1 > ! Index Cond: (unique1 > 42000) > ! (3 rows) > select max(unique1) from tenk1 where unique1 > 42000; > max > 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? Or perhaps the question to ask is whether a MinMaxAgg path can be marked parallel-safe. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers