Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhi8U-00007n-Nz for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Aug 2017 20:08:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dhi8U-0003nQ-5b for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Aug 2017 20:08: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 1dhi8T-0003lR-DH for pgsql-hackers@postgresql.org; Tue, 15 Aug 2017 20:08:21 +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 1dhi8Q-0006T9-5F for pgsql-hackers@postgresql.org; Tue, 15 Aug 2017 20:08:20 +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 v7FK8Emw031095; Tue, 15 Aug 2017 16:08:14 -0400 From: Tom Lane To: Robert Haas cc: "pgsql-hackers@postgresql.org" Subject: Re: [COMMITTERS] pgsql: Simplify plpgsql's check for simple expressions. In-reply-to: References: <23425.1502822098@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Tue, 15 Aug 2017 15:15:39 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <31093.1502827694.1@sss.pgh.pa.us> Date: Tue, 15 Aug 2017 16:08:14 -0400 Message-ID: <31094.1502827694@sss.pgh.pa.us> 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 Robert Haas writes: > On Tue, Aug 15, 2017 at 2:34 PM, Tom Lane wrote: >> I assume (haven't looked) that I could hack the plpgsql code to prevent >> generating a parallel plan when it's decided the command is a simple >> SELECT. But I wonder whether that's the right place to fix it. Does >> it ever make sense to parallelize a plan that can't possibly benefit? >> IOW I am not sure that we should carry force_parallel_mode this far. > Well, I think the point of force_parallel_mode is to try running > things in workers when it's legal but not necessarily beneficial, so > I'd be disinclined to nerf this too much, but it might be OK to nerf > it a little bit. Fair enough. > Off-hand, I'd say the obvious options are: > (1) teach exec_simple_check_plan() to consider everything non-simple > when force_parallel_mode is not off, or > (2) teach exec_save_simple_expr() to see through a Gather node to the > Result node underneath I had been looking into (3) get plpgsql to drop the CURSOR_OPT_PARALLEL_OK bit when it decides the query is simple. But because (a) that bit is set before we make the test, in current behavior, and (b) there are various SPI interfaces in the way of changing it later, that approach is looking pretty messy. I like your plan (2). It's not much code and it lends itself to having a run-time check, rather than just an Assert, that we found a Result node. That seems like a good idea now that we've found the assumption isn't bulletproof. However, do we need to worry about the planner putting some nontrivial computation into the Gather's tlist instead of the Result? 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