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 1fiQNy-00079j-Li for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Jul 2018 20:27:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fiQNx-0002mt-04 for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Jul 2018 20:27:49 +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 1fiQNw-0002mm-Lk for pgsql-hackers@lists.postgresql.org; Wed, 25 Jul 2018 20:27:48 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fiQNt-0002vF-9p for pgsql-hackers@postgresql.org; Wed, 25 Jul 2018 20:27:47 +0000 Received: by mail-lj1-x242.google.com with SMTP id q5-v6so7782871ljh.12 for ; Wed, 25 Jul 2018 13:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Y5SrY2F80sBjblOHNQWAbBDs9xL41K2bPsqVckaHKHI=; b=AnHg4tAlDh6ujXT1py254ti6rHgIrFQypkhkuiFKzWgZBVl09odCeqv9SyQ0dcbN64 LgJhtXarxQ3aDLywi+SvwHKkec+QiokZeAS279yQHuPpwbyPE2JG8Z5o1wSHE8HffjgJ 3kUjhxWzcd+Z2Tow/hC30iqniFj5PaksE7gUT07vxpnnZtZ67OAtXX96sUokP+IU5x10 TuYywC1WxWNFsgV19ZPigE9VH+vhRp9wcOUPsHNTCr67on6zN8i2m1bKty9sh3N5wyMx nckfCnJ3O7M1d1dlSBp34xbAHFp64uOKJNbzusRvfdmrRmQShniYlC/tExjYKQC4S5wA m7Vw== 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=Y5SrY2F80sBjblOHNQWAbBDs9xL41K2bPsqVckaHKHI=; b=j3cyS0ixnnqjW9elwsqx4iW/wNj/pZ4eBUd7al1AjpwAjVzxuhYqryY0jVOYXFhX91 LH01rLOYpdAkz8w3q/NGLe9V31bsXCn75WxtdRMxMLvVjiSGUsP9BIu6OC6fZVWdtcR3 l1uYxk80WY3Hvhi2uO5pHnaQE2aWfKZoYYmPJz+Cmhekv/NPFBTwSaw8HZvLoIBOCTr8 jKVIN3YsrImTNqJ64eMCHz34dZV89Pc/GooTVyNczVRh0JnrXjRtOmRAu3cGwCF9KQWo XC8ZR63ZbSzTw1i/CkjEqANqqzIGRW6DMZsEiuPhZkurlyLDUigDoxYE81L6Bw3C3dt9 GLRQ== X-Gm-Message-State: AOUpUlGx2LFzFYO5KuLA/YkveJc7hS5FWYMgXIBSzZ5fT2pVozQSDqGu aSOWcbLfp0yNZf2A337VzgYpqyNp2R+gAHrPXjK8EA== X-Google-Smtp-Source: AAOMgpfnOfp1hH/K54KWcAoyLrp0zEEmHqXiZGADv3AkzdDMfF4hq06kGPyz0afYlt/zTYEocFK3qVYXcGtD7afcbqM= X-Received: by 2002:a2e:540d:: with SMTP id i13-v6mr6570651ljb.51.1532550462752; Wed, 25 Jul 2018 13:27:42 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:e508:0:0:0:0:0 with HTTP; Wed, 25 Jul 2018 13:27:41 -0700 (PDT) In-Reply-To: <5B5712C8.9030404@lab.ntt.co.jp> References: <5AFC0865.8050802@lab.ntt.co.jp> <5AFD6580.5090308@lab.ntt.co.jp> <5AFE81CC.8000508@lab.ntt.co.jp> <5B17C5EC.1090602@lab.ntt.co.jp> <5B1E5071.1000704@lab.ntt.co.jp> <5B23A964.9020800@lab.ntt.co.jp> <5B28FB19.3090809@lab.ntt.co.jp> <20180703163519.tsigyic5xefunv74@alap3.anarazel.de> <5B3C2A4E.5030901@lab.ntt.co.jp> <5B4F2BE9.3000304@lab.ntt.co.jp> <5B55886F.5090906@lab.ntt.co.jp> <5B5712C8.9030404@lab.ntt.co.jp> From: Robert Haas Date: Wed, 25 Jul 2018 16:27:41 -0400 Message-ID: Subject: Re: Expression errors with "FOR UPDATE" and postgres_fdw with partition wise join enabled. To: Etsuro Fujita Cc: Andres Freund , Ashutosh Bapat , Rajkumar Raghuwanshi , pgsql-hackers , Tom Lane Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Jul 24, 2018 at 7:51 AM, Etsuro Fujita wrote: >> Isn't that assumption fundamental to your whole approach? > > I don't think so. What I mean here is: currently the subplan would be a > scan/join node, but in future we might have eg, a Sort node atop the > scan/join node, so it would be better to update the patch to handle such a > case as well. But how would you do that? >>>> I think that's a bad idea. The target list affects lots >>>> of things, like costing. If we don't insert a ConvertRowTypeExpr into >>>> the child's target list, the costing will be wrong to the extent that >>>> ConvertRowTypeExpr has any cost, which it does. >>> >>> >>> Actually, this is not true at least currently, because >>> set_append_rel_size >>> doesn't do anything about the costing: >> >> >> Why would it? Append can't project, so the cost of any expressions >> that appear in its target list is irrelevant. What is affected is the >> cost of the scans below the Append -- see e.g. cost_seqscan(), which >> uses the data produced by set_pathtarget_cost_width(). > > By set_rel_size()? Sorry, I don't understand what you mean by this. > I'm not sure that's a good idea, because I think we have a trade-off > relation; the more we make create_plan simple, the more we need to make > earlier states of the planner complicated. > > And it looks to me like the partitionwise join code is making earlier (and > later) stages of the planner too complicated, to make create_plan simple. I think that create_plan is *supposed* to be simple. Its purpose is to prune away data that's only needed during planning and add things that can be computed at the last minute which are needed at execution time. Making it do anything else is, in my opinion, not good. > When considering paritionwise joining, it would make things complicated to > have a ConvertRowtypeExpr in a partrel's targetlist, because as discussed > upthread, it deviates from the planner's assumption that a rel's targetlist > would only include Vars and PHVs. So, I propose to include a child > whole-row Var in the targetlist instead, in which case, we need to fix the > Var after the fact, but can avoid making many other parts of the planner > complicated. Well, I could have the wrong idea here, but I tend to think allowing for ConvertRowTypeExpr elsewhere won't be that bad. Does anyone else want to weigh in on this issue? Tom, perhaps? -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company