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 1ng0aW-0007Ly-DE for pgsql-hackers@arkaria.postgresql.org; Sun, 17 Apr 2022 08:48:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ng0aV-00077F-9D for pgsql-hackers@arkaria.postgresql.org; Sun, 17 Apr 2022 08:48:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ng0aU-00074e-Te for pgsql-hackers@lists.postgresql.org; Sun, 17 Apr 2022 08:48:54 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ng0aO-0000PE-Ct for pgsql-hackers@lists.postgresql.org; Sun, 17 Apr 2022 08:48:53 +0000 Received: by mail-ej1-x632.google.com with SMTP id l7so22313264ejn.2 for ; Sun, 17 Apr 2022 01:48:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=p40tzOfwRbD/ooTUh0q9yTJv30wJhiBx5FXBXCOvZ6Y=; b=QQq23/mjPU6pBnopvXxhaG07byRhyqqonB/ZX976nC5m7GxazfYNEhVrEOdlgEzUSu OPlwryJeovvjzfLXxClolQoteWwqfKBT93QghBn325L3/udsCST6z9wo8N/2oy383IgB EIKTw0tA6U3Jrc25pNVh9ByH4XNNcyhQcHcPAIWVWyb37OaoSbfZtQQggzC9yiQ9iBA1 FdLbPYgUpgahwCIhjgLvWaVhNONyjcwl7GEEsxWUF6cakR5Lldw6hn3P9F6LNEQ0Zavf 6H4KR6cc2yg6wk7J+hG0iDaPgZG6jlZPzTz6eBQB8KI677Irfb5jGWQIp/OVHegLVr5F zKYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=p40tzOfwRbD/ooTUh0q9yTJv30wJhiBx5FXBXCOvZ6Y=; b=66HPlhuVfZPQt/AcDNGURW7sHk0o05EEJD5dDrE1ypmdBb5zr0SEqofxOKDlb69fJT /N2yLq5NslEeJartBTYr4jXuDN1l+g2edCIr2AH7UQItjvMmYiyThkvdf4PQD5M6ucYo fWwOaHHc4qdJk2LXneTQb7MLhIPj0xxAYkTNPSnDYS+6jzZSRBVyKgBtKBGGTzWwS/eO QH0ESxNzf8W+ksA6HD8h2QpkQzzAvrHsL/PWbztoVRcG7Fms60Lk7Tce2xtvR2Ga4Q1+ QQvkhZjhcPyF9KA0rbGLi4aLQmc0bsPP15dnDLmsFZAyp+JsUcA2UgU8dgfl6FpReUyr 8HQw== X-Gm-Message-State: AOAM532lHMhdmrz041AtG5v3z6Z8BtuRbVsW3DEJ0FzbfhirVuQcsmUy LxMBMX6COzOobYsdoVDPvYg/H0V+t6enHKKoN68= X-Google-Smtp-Source: ABdhPJzOLlJcpcMH8TGIOjo7yQzzDkfuJp4rGYT1SxZ4fSfawBQ5aqwAa3+9GZAUI0JOTnJ2gDlXKT0yLbct+cM+7Xw= X-Received: by 2002:a17:907:7f09:b0:6e8:db1a:2fc9 with SMTP id qf9-20020a1709077f0900b006e8db1a2fc9mr5413106ejc.522.1650185326286; Sun, 17 Apr 2022 01:48:46 -0700 (PDT) MIME-Version: 1.0 References: <20220411024101.GC26620@telsasoft.com> In-Reply-To: From: Etsuro Fujita Date: Sun, 17 Apr 2022 17:49:55 +0900 Message-ID: Subject: Re: Defer selection of asynchronous subplans until the executor initialization stage To: Zhihong Yu Cc: Justin Pryzby , Alexander Pyhalov , "Andrey V. Lepikhov" , Kyotaro Horiguchi , PostgreSQL Developers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Apr 11, 2022 at 11:44 AM Zhihong Yu wrote: > On Sun, Apr 10, 2022 at 7:41 PM Justin Pryzby wrote: >> On Sun, Apr 10, 2022 at 06:46:25AM -0700, Zhihong Yu wrote: >> > Looking at the second hunk of the patch: >> > FdwRoutine *fdwroutine = path->parent->fdwroutine; >> > ... >> > + if (IsA(plan, Result)) >> > + return false; >> > >> > It seems the check of whether plan is a Result node can be lifted ahead of >> > the switch statement (i.e. to the beginning of mark_async_capable_plan). >> > >> > This way, we don't have to check for every case in the switch statement. >> >> I think you misread it - the other branch says: if (*not* IsA()) >> > No, I didn't misread: > > if (!IsA(plan, Result) && > mark_async_capable_plan(plan, > ((ProjectionPath *) path)->subpath)) > return true; > return false; > > If the plan is Result node, false would be returned. > So the check can be lifted to the beginning of the func. I think we might support more cases in the switch statement in the future. My concern about your proposal is that it might make it hard to add new cases to the statement. I agree that what I proposed has a bit of redundant code, but writing code inside each case independently would make it easy to add them, making code consistent across branches and thus making back-patching easy. Thanks for reviewing! Best regards, Etsuro Fujita