Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qxhUD-002rC2-F9 for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Oct 2023 05:40:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qxhUC-000gfb-3E for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Oct 2023 05:40:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qxhR3-000cjv-J8 for pgsql-hackers@lists.postgresql.org; Tue, 31 Oct 2023 05:37:05 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qxhQw-003C1x-L7 for pgsql-hackers@postgresql.org; Tue, 31 Oct 2023 05:37:04 +0000 Received: from [172.20.10.2] (ppp-49-237-42-28.revip6.asianet.co.th [49.237.42.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: a.lepikhov@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id 91AFBE203CB; Tue, 31 Oct 2023 08:36:53 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1698730617; bh=TtQARWKCo4679NTb3a9YpWis2G2paXvNokcEGZx+1u0=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=vW2Vs+KYnb4Qd9R2RHEJin1aiTOXK2s6+S0B9az5G3QO0uAPFlalQlkeZFQ8qM+tl ZkhZ2l1p+JkjheQpQ0oBZRo/dkJEQhbqxm4DDE/aOEkurS0WVNHAZovLUx6pC7MIZY ypZ7YkWqMZJT28o6jVIa7KIhoNB2KI9IbengkMSZR/TVId8eRMO3nhBH4SPUeRzAmh PJMyFnN9OktymOa5w8pqNG5qv0cbvM9jeCRt32soot5yBCCtXIMDClnyZra12N8714 FEa26qB/ifSDglB+V1jr2ei/Amib5PY/VbzqFcCONFB/OQydxC2ZRTDHUNoZHyEgl8 HZ8+NeGyoqk+w== Message-ID: Date: Tue, 31 Oct 2023 12:36:42 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: A performance issue with Memoize Content-Language: en-US To: Richard Guo Cc: PostgreSQL-development , David Rowley , Tom Lane References: <1d55df6d-92cb-4bbd-9a4c-0d05bb6bc91d@postgrespro.ru> From: Andrei Lepikhov Organization: Postgres Professional In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 30/10/2023 14:55, Richard Guo wrote: > > On Thu, Oct 26, 2023 at 12:07 PM Andrei Lepikhov > > wrote: > > Do you've thought about the case, fixed with the commit 1db5667? As I > see, that bugfix still isn't covered by regression tests. Could your > approach of a PARAM_EXEC slot reusing break that case? > > > Hm, I don't think so.  The issue fixed by commit 1db5667 was caused by > sharing PARAM_EXEC slots between different levels of NestLoop.  AFAICS > it's safe to share PARAM_EXEC slots within the same level of NestLoop. > > The change here is about sharing PARAM_EXEC slots between subquery's > subplan_params and outer-relation variables, which happens within the > same level of NestLoop. > ... > Did you notice a case that the change here breaks? > > Hi Tom, could you share your insights on this issue and the proposed > fix? I think your patch works correctly so far. I mentioned the commit 1db5667 because, as I see, the origin of the problem was parallel workers. I have thought about pushing Memoize down to a parallel worker and couldn't imagine whether such a solution would be correct. Sorry if I disturbed you in vain. -- regards, Andrei Lepikhov Postgres Professional