Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kjU7r-0004Zm-PY for pgsql-hackers@arkaria.postgresql.org; Sun, 29 Nov 2020 21:20:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kjU7q-0000UA-EU for pgsql-hackers@arkaria.postgresql.org; Sun, 29 Nov 2020 21:20:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kjU7q-0000U3-7U for pgsql-hackers@lists.postgresql.org; Sun, 29 Nov 2020 21:20:54 +0000 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kjU7i-0002qn-4Q for pgsql-hackers@postgresql.org; Sun, 29 Nov 2020 21:20:53 +0000 Received: by mail-ed1-x543.google.com with SMTP id v22so12717719edt.9 for ; Sun, 29 Nov 2020 13:20:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Ko4LUN1tDo5TaHLPczB4deHxAgAstDaWCPlTPQ0dk1g=; b=zcckKxLmlKdsPvVClcO1MMt9F5nxkHqtiBKFB6UU31bO3ZNVb4yurQmlc8goMc2j4h Q8CUedNrye41ArM2MA6pmXbhxaHrObOSFUGBv11h3kR5BQsPyKAjjehMVYFSUmp4o3gX s92iVdCuVuxWYJgKmRqBAi/Ldf7kziutRN6Q1ClpzBatSFYKmJzfF/0eAPLIUcjkUMma x6JSkgFFXKPJtK1x1Qofre3aj1SkCDuKmx30nLpDB5Y7J64h7W1vw2VC7hGrU+MHFJGF ol0aU+/QOwBqZ7wua3xnk/gih9FaiC0a0+zjRa5AZ2T8sxyLWg3s3pb1McLbOvwm0f4c EUCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Ko4LUN1tDo5TaHLPczB4deHxAgAstDaWCPlTPQ0dk1g=; b=RFxjd9OaLzoZv6XtFyv7HLqzwFiAhTe2V5qYjBE1WV7uJKBDjtxqvCQth5x/p2q35i nLiPzVk+vl7Bb0lywn8osCRRQNkJz0A7NSZnagcPkirq0qkhweCOtpdq/EfW1tpaGMFi BNMNcKutNxAQ5zgemZBSrtB9edit5HwnGphFgVRh3x9bxkK6wmhXSoCWXV7DuRGAHx8a kN6fDI9dTEz0R0O2EPDKzqy3nCiPy6KSO4lqjUFAMpEIqPwi4ce5c4uclRSAAuNwxKuK DKFB/6HSewItbtZKssQPSWqgzOA5S81qykMDUPNANOhf4fWXA71XlZfXRbe7+MUetZ8R OicQ== X-Gm-Message-State: AOAM533eV0Ve7eb7XmCO+X1JaUW58iQHIjoCX0ZHJBQi4crPfFAPOC2p a21Oyq8wO23CYYujWj0jQSNfNvN6x4Po+3FHV8NK0X9qRZYGNHXligi7c8c8s4AVy87Ne2+T/4a 6T+uF76BpiRnSCIrKJb3vb/C8pnUiJYuLFNF7me2WZn50pFTFhY5vZ6lDJ5SzcRu4wsF2yLMdNy sRRqADwV8Mw+PxM9FdbtsTyet5R4y8C4SAe5TF X-Google-Smtp-Source: ABdhPJwgJyjh2DzDbodMUsWg8F9RCL4DONcp0hTNRu5+sg2ihKT/xzr5Xlr23ubzKjWLXBA2yCI9vA== X-Received: by 2002:a05:6402:3198:: with SMTP id di24mr3059822edb.203.1606684844729; Sun, 29 Nov 2020 13:20:44 -0800 (PST) Received: from [10.137.0.18] (ip-86-49-245-76.net.upcbroadband.cz. [86.49.245.76]) by smtp.gmail.com with ESMTPSA id f7sm7811822ejd.13.2020.11.29.13.20.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Nov 2020 13:20:43 -0800 (PST) Subject: Re: Fix generate_useful_gather_paths for parallel unsafe pathkeys To: James Coleman Cc: pgsql-hackers , luis.roberto@siscobra.com.br, Tom Lane , Robert Haas References: <28a4f17e-0b81-8bd5-d40f-e5d69d8101b1@enterprisedb.com> From: Tomas Vondra Message-ID: Date: Sun, 29 Nov 2020 22:20:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 11/29/20 3:26 PM, James Coleman wrote: > On Mon, Nov 23, 2020 at 8:35 AM James Coleman wrote: >> >> On Sun, Nov 22, 2020 at 4:59 PM Tomas Vondra >> wrote: >>> ... >>> Thanks for the patches, I'll take a closer look next week. The 0002 >>> patch is clearly something we need to backpatch, not sure about 0001 as >>> it essentially enables new behavior in some cases (Sort on unsorted >>> paths below Gather Merge). >> >> Thanks for taking a look. >> >> I had the same question re: backporting. On the one hand it will >> change behavior (this is always a bit of a gray area since in one >> sense bugs change behavior), but IMO it's not a new feature, because >> the code clearly intended to have that feature in the first place (it >> creates gather merges on top of a full sort). So I'd lean towards >> considering it a bug fix, but I'm also not going to make that a hill >> to die on. >> >> One semi-related question: do you think we should add a comment to >> prepare_sort_from_pathkeys explaining that modifying it may mean >> find_em_expr_for_rel needs to be updated also? > > Here's an updated patch series. > > 0001 and 0002 as before, but with some minor cleanup. > 0001 - seems fine 0002 - Should we rename the "parallel" parameter to something more descriptive, like "require_parallel_safe"? > 0003 disallows SRFs in these sort expressions (per discussion over at [1]). > OK, but I'd move the define from tlist.c to tlist.h, not optimizer.h. > 0004 removes the search through the target for matching volatile > expressions (per discussion at [2]). > OK > 0005 adds the comment I mentioned above clarifying these two functions > are linked. > Makes sense. I wonder if we need to be more specific about how consistent those two places need to be. Do they need to match 1:1, or how do people in the future decide which restrictions need to be in both places? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company