Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAdv7-0006GC-E4 for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Oct 2018 16:34:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gAdv5-0007NB-D0 for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Oct 2018 16:34:39 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAdv5-0007N4-2X for pgsql-hackers@lists.postgresql.org; Thu, 11 Oct 2018 16:34:39 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAduy-00009b-4g for pgsql-hackers@lists.postgresql.org; Thu, 11 Oct 2018 16:34:37 +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 w9BGYS4Q005396; Thu, 11 Oct 2018 12:34:28 -0400 From: Tom Lane To: Robert Haas , Jeevan Chalke cc: pgsql-hackers@lists.postgresql.org Subject: Soon-to-be-broken regression test case MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <5394.1539275668.1@sss.pgh.pa.us> Date: Thu, 11 Oct 2018 12:34:28 -0400 Message-ID: <5395.1539275668@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk The last test case in select_parallel.sql, added in commit dc1057fc, currently generates a plan like this: CREATE VIEW tenk1_vw_sec WITH (security_barrier) AS SELECT * FROM tenk1; EXPLAIN (COSTS OFF) SELECT 1 FROM tenk1_vw_sec WHERE EXISTS (SELECT 1 WHERE unique1 = 0); QUERY PLAN ------------------------------------------------------------------- Subquery Scan on tenk1_vw_sec Filter: (alternatives: SubPlan 1 or hashed SubPlan 2) -> Gather Workers Planned: 4 -> Parallel Index Only Scan using tenk1_unique1 on tenk1 SubPlan 1 -> Result One-Time Filter: (tenk1_vw_sec.unique1 = 0) SubPlan 2 -> Result (10 rows) I have been fooling around with a patch to allow pull-up of sub-selects that lack any FROM, along the lines discussed in https://www.postgresql.org/message-id/15944.1521127664@sss.pgh.pa.us I find that it is smart enough to reduce that EXISTS to a plain expression, yielding QUERY PLAN ---------------------------------------------------- Subquery Scan on tenk1_vw_sec -> Index Only Scan using tenk1_unique1 on tenk1 Index Cond: (unique1 = 0) (3 rows) While that's obviously a far better plan, it does not meet this test case's stated goal of testing the interaction of subqueries with parallel query. Could you suggest a less trivial subquery that will still do what you intended? regards, tom lane