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 1sUemy-004fAx-Nd for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jul 2024 04:00:12 +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 1sUemw-008Y8o-IO for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jul 2024 04:00:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sUemw-008Y8g-8q for pgsql-hackers@lists.postgresql.org; Fri, 19 Jul 2024 04:00:10 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sUemp-000JcR-Sx for pgsql-hackers@lists.postgresql.org; Fri, 19 Jul 2024 04:00:10 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-52ed741fe46so1497882e87.0 for ; Thu, 18 Jul 2024 21:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721361603; x=1721966403; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=AS/CcbwkEaxzQ2pMxJ+UR8HoDZRD1hrvcaEhk+2kCrg=; b=Oe4cHbXs218FVaANbJfkQ53VK6lPOauGBHn9woyNSbisjKWNnN0LQOjQiUuDrKzh4n 7mWQL422Ja2SY79il0T3xJ3YDKzDIqO39hla+agiAMI5xXx4Pr/38gk9f5Aki67pqLb9 udyuOrn0UEB2pvzKzslTYoE9wmeXVgGjX0v8Lcq6SMqzptufYFn6NZCsYrYhKYS66ENq 65LKRDXsvsU7N7Evpx6EAtfmV+KIS75jxprADELP3JIy9TasULr66UgaK1hdfEjVzOj2 VFx1BCKu9qLykvAGVnYhDbBk6HDZzYqVUziAoGSsO154riyHxSLaJK9CMX8IKRYUxyhf y6fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721361603; x=1721966403; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AS/CcbwkEaxzQ2pMxJ+UR8HoDZRD1hrvcaEhk+2kCrg=; b=aTbUkplERZCHoxzYD5bptsFrC+awQyKeDMgQyrM3J67oL6bHj8Uikdiqmm8Ryui3/t 7JIZmAgm20ZodA/dwwGYQymuevHdUj8swCmMY7mM5LYKVYUOcV1xfkhsDNAyqTMT45Ni Or2AZfsoWXQMpPEHhJ2c9GQneCHD+3hN/UjChfPmFbQFRpJHOpgjkO+naVLyrHvqsSFa zgkxwXE2jZKzcgemAXwYhreuwtgHqE16Gkej+QQolo3jI/jhytn4sp0xD4HKtrxQDKqy T3a13RwN/m29AMok0jjC5XDNmCosTQC5vQsgsvXc33ECG1laHuhLw7KdnEKDDAclrGxe WHOg== X-Forwarded-Encrypted: i=1; AJvYcCUarcoP47fEon8CuxFzEMkKQe0xa5VPyDOQd+Ku1FWAD4gAHbvuwu4VsCpM18QO/QrMMe3JmQtuGS4tqpoNjftE6XXkrWlcZ+XWtpPxAKBi3ukD X-Gm-Message-State: AOJu0Yw1l8E7aP8IGUVHwKy878YNXtigoBLTMzVec6B2O3ixRpUBbwLF CFQgzPyS/KMUMFYbAxoWhpAw3WzDIsphWXHtuxQBbNqnRMpLBUSk X-Google-Smtp-Source: AGHT+IH2qCCBdtV3qsrh7as5t/DCsXBettvB6eO+1YousRCotRxysKLKdvzcSAe4dF26gSdiJEJbZg== X-Received: by 2002:a05:6512:3d0c:b0:52e:be1f:bf7f with SMTP id 2adb3069b0e04-52ee53da928mr4800668e87.27.1721361602873; Thu, 18 Jul 2024 21:00:02 -0700 (PDT) Received: from [1.0.0.7] ([178.155.21.244]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52ef55773b8sm64940e87.240.2024.07.18.21.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Jul 2024 21:00:02 -0700 (PDT) Message-ID: <60961f98-4976-531a-82e8-3a4a97d03ee1@gmail.com> Date: Fri, 19 Jul 2024 07:00:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: Should consider materializing the cheapest inner path in consider_parallel_nestloop() To: Richard Guo Cc: Tender Wang , Tomasz Rybak , pgsql-hackers@lists.postgresql.org, robertmhaas@gmail.com, David Rowley , "Fujii.Yuki@df.MitsubishiElectric.co.jp" References: <9FBD029B-3E71-4D47-AB54-938C73A4668F@yandex-team.ru> <5641923793cef7706395a34e62538b75d05e498b.camel@post.pl> <7c09a439-e48d-5460-cfa0-a371b1a57066@gmail.com> Content-Language: en-US From: Alexander Lakhin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello Richard, 18.07.2024 17:30, Richard Guo wrote: > The problemed plan is a non-parallel nestloop join. It's just chance > which join order the planner will pick, and slight variations in > underlying statistics could result in a different displayed plan. > From the two verbose plans, we can see slight variations in the > statistics for the parallel seqscan of tenk1. > > -> Parallel Seq Scan on public.tenk1 t1 (cost=0.00..370.00 rows=2500 > width=244) > > VS. > > -> Parallel Seq Scan on public.tenk1 t1 (cost=0.00..369.99 rows=2499 > width=244) > > I have no idea why the underlying statistics changed, but it seems > that this slight change is sufficent to result in a different plan. I think it could be caused by the same reason as [1] and I really can easily (without multiple instances/loops. just with `make check`) reproduce the failure with cranky-ConditionalLockBufferForCleanup.patch (but targeted for "VACUUM ANALYZE tenk1;"). > According to the discussion in [1], I think what we wanted to test > with this query is that parallel nestloop join is not generated if the > inner path is not parallel-safe. Therefore, I modified this test case > to use a lateral join, rendering the inner path not parallel-safe > while also enforcing the join order. Please see attached. The modified test survives my testing procedure. Thank you for the patch! [1] https://www.postgresql.org/message-id/flat/66eb9a6e-fc67-a230-c5b1-2a741e8b88c6%40gmail.com Best regards, Alexander