Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fdTN1-00078o-N3 for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Jul 2018 04:38:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fdTMy-0003bf-Vi for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Jul 2018 04:38:20 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fdTMy-0003bQ-GM for pgsql-hackers@lists.postgresql.org; Thu, 12 Jul 2018 04:38:20 +0000 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fdTMu-0006bB-Mu for pgsql-hackers@postgresql.org; Thu, 12 Jul 2018 04:38:18 +0000 Received: by mail-pf0-x241.google.com with SMTP id j3-v6so19797333pfh.11 for ; Wed, 11 Jul 2018 21:38:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=3ugDFyuonCvZKv5sFWp0tQnNpMfCaAUPUcVEJVkyocU=; b=bZE1ReJ9xokVf0kHyvmlezdRr3zknfsKNAhH188siYdE7OcfRAU+QPoNoKitAfoAGz iZPj1e03rRfJbR7AqvgICEdMkhGjQB3BB3oFYeMS3tqvK4yontRkePleISjzTPGbK/84 zDu3Qp4wHiZ6CqbL/hgxYB4pX7yRuqFNqQJgTCHia/HALCwnFgQdPk+gIR6UZMIfAY5t o+c4PaU7Xb6pE9NiqZBRIYL5HDeIV1QCjYYLni2TXjX7psaS1CCa6eaVMFlbM80Pl3ad s9sfs8ZAym6b0JwLP6LQnZJKQhZTc+wRzEz3K75y2uU4OhCJti57UXLrHtLMivIvXsBk b6dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=3ugDFyuonCvZKv5sFWp0tQnNpMfCaAUPUcVEJVkyocU=; b=AmfMzdHILFS4qnwS2caOvh86NBvo2y7SFshNF/9RVjINwtg+P2kEtYWsaEOlXhqZ0c 6n7MYYJYLKKcYSZzpWqUDZlA+mWSHa4dB3dM8hywPH+QbycyYQ8Nq+Xx/cChd+HRtip5 4TU+JKTh0by/ypMpvQz0wO6owOHsojEmPzkoO9MdjPiT8b3qPEiI03ssm/em6394G9VT cqxGGx+J9GwQbb+tFfipXDRJjvtiBX2Af38UIu4gsxO8+Dr+lsL5e+d8JhIcr3uZt8Qk vxzF1Ct5z02Jf3126ROC8t76ZM4GOAgI83wksumpWK5OVW3mGTsb+H9f1H+nuAuW2Nlc cxYQ== X-Gm-Message-State: AOUpUlHCGatPZ6IDLM0BhjcEdVZVkvI0A0IMuc1h/CUI7+f3xGDWpgtw OGAQJf5CypFqXR4wg+96VV4Zl9gXGerxDeGTBA6lIw== X-Google-Smtp-Source: AAOMgpeTyxv3coqzbKhb1xkGoCXh0T+dmRH2EjINJh+xx7Csg9vJOhshveoLZ+f06dYDG2Hyp6sOnPh+ivCZr9EZSwY= X-Received: by 2002:a63:6986:: with SMTP id e128-v6mr653062pgc.294.1531370294848; Wed, 11 Jul 2018 21:38:14 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a17:90a:b43:0:0:0:0 with HTTP; Wed, 11 Jul 2018 21:38:13 -0700 (PDT) In-Reply-To: <5B46CBB3.2090300@lab.ntt.co.jp> References: <5B1E5071.1000704@lab.ntt.co.jp> <5B23A964.9020800@lab.ntt.co.jp> <5B28FB19.3090809@lab.ntt.co.jp> <5B362B38.2000103@lab.ntt.co.jp> <5B3CB833.4040005@lab.ntt.co.jp> <5B3F4BAA.3050601@lab.ntt.co.jp> <5B4340E9.3030707@lab.ntt.co.jp> <5B434886.9010107@lab.ntt.co.jp> <5B442A40.2040903@lab.ntt.co.jp> <5B45B777.7010502@lab.ntt.co.jp> <5B46CBB3.2090300@lab.ntt.co.jp> From: Ashutosh Bapat Date: Thu, 12 Jul 2018 10:08:13 +0530 Message-ID: Subject: Re: Expression errors with "FOR UPDATE" and postgres_fdw with partition wise join enabled. To: Etsuro Fujita Cc: Rajkumar Raghuwanshi , pgsql-hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Jul 12, 2018 at 9:02 AM, Etsuro Fujita wrote: > (2018/07/11 20:02), Ashutosh Bapat wrote: >> >> On Wed, Jul 11, 2018 at 1:23 PM, Etsuro Fujita >> wrote: >>> >>> Actually, even if we could create such an index on the child table and >>> the >>> targetlist had the ConvertRowtypeExpr, the planner would still not be >>> able >>> to use an index-only scan with that index; because check_index_only would >>> not consider that an index-only scan is possible for that index because >>> that >>> index is an expression index and that function currently does not >>> consider >>> that index expressions are able to be returned back in an index-only >>> scan. >>> That behavior of the planner might be improved in future, though. > > >> Right and when we do so, not having ConvertRowtypeExpr in the >> targetlist will be a problem. > > > Yeah, but I don't think that that's unsolvable; because in that case the CRE > as an index expression could be converted back to the whole-row Var's > rowtype by adding another CRE to the index expression for that conversion, I > suspect that that special handling could allow us to support an index-only > scan even when having the whole-row Var instead of the CRE in the > targetlist. I am not able to understand this. Can you please provide an example? > (Having said that, I'm not 100% sure we need to solve that > problem when we improve the planner, because there doesn't seem to me to be > enough use-case to justify making the code complicated for that.) Anyway, I > think that that would be a matter of future versions of PG. I am afraid that a fix which just works only till we change the other parts of the system is useful only till that time. At that time, it needs to be replaced with a different fix. If that time is long enough, that's ok. In this case, I agree that if we haven't heard from users till now that they need to create indexes on whole-row expressions, there's chance that we will never implement this feature. > >>>> At places in planner we match equivalence members >>>> to the targetlist entries. This matching will fail unexpectedly when >>>> ConvertRowtypeExpr is removed from a child's targetlist. But again I >>>> couldn't reproduce a problem when such a mismatch arises. >>> >>> >>> >>> IIUC, I don't think the planner assumes that for an equivalence member >>> there >>> is an matching entry for that member in the targetlist; what I think the >>> planner assumes is: an equivalence member is able to be computed from >>> expressions in the targetlist. >> >> >> This is true. However, >> >>> So, I think it is safe to have whole-row >>> Vars instead of ConvertRowtypeExprs in the targetlist. >> >> >> when it's looking for an expression, it finds a whole-row expression >> so it think it needs to add a ConvertRowtypeExpr on that. But when the >> plan is created, there is ConvertRowtypeExpr already, but there is no >> way to know that a new ConvertRowtypeExpr is not needed anymore. So, >> we may have two ConvertRowtypeExprs giving wrong results. > > > Maybe I'm missing something, but I don't think that we need to worry about > that, because in the approach I proposed, we only add CREs above whole-row > Vars in the targetlists for subplans of an Append/MergeAppend for a > partitioned relation at plan creation time. There's a patch in an adjacent thread started by David Rowley to rip out Append/MergeAppend when there is only one subplan. So, your solution won't work there. -- Best Wishes, Ashutosh Bapat EnterpriseDB Corporation The Postgres Database Company