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 1ka41w-0000BN-EZ for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Nov 2020 21:39:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ka41v-0001Yc-Dn for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Nov 2020 21:39:51 +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 1ka41v-0001YV-2R for pgsql-hackers@lists.postgresql.org; Tue, 03 Nov 2020 21:39:51 +0000 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ka41q-0000LK-5L for pgsql-hackers@postgresql.org; Tue, 03 Nov 2020 21:39:50 +0000 Received: by mail-ed1-x542.google.com with SMTP id a71so14736926edf.9 for ; Tue, 03 Nov 2020 13:39:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Yb8qThQdkDz1w136+VHcHR/1O5K59w1GJb4+lg3lQMg=; b=srGwuRC0bB0xs9j59/I3bUolm78XdKLkzdJKrAa6nRbbn/qoIl7Rzs3D542F3f3pqm 40T4Eo6RM/3+ygCHS0TEQmUnoINqeEWJ5NTh7wQng1h1jtcjIrq8HMAW/VCOfCYsvqeM Tp462FCpzHazVJdleD5Zyiuxx3asN93HLfShi+hfPcZ82oP8RcvP2m5puYuhEvDg2k4s gzAoA2sQj2i3SsYuC2vBinAbn2egfdPAAti92fQu/ebq47knw/yzFFCsyJdIyBBPyWHj fIg45llgPPvTPrvpBOAt1UZWGlEPRlJt7hQZZUrmtbP2lDKxDd8lrW7ga3al/TkkdmS2 KnDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Yb8qThQdkDz1w136+VHcHR/1O5K59w1GJb4+lg3lQMg=; b=kA8XZ3R/EYVK2SEM1fZPNNqr3IGZgCtn/g/b8B952cTBBMo4ffFtoR6vGh+2OZVq6f R+5vxp1kVhqO8kD4RFRfCDP/psynu9CXjcAIDCnVOVYhpkVUoKHXH13t4/QB578XwJVJ TEiE0p+fs3eLvBfIFOYOcAJ+aGiJPXZggD3b69od0G9DDcF4RWwVOE3dOS+qY9xl0V1H 7DDKWFsleYwyMdpAwgIzocxLXxoeiZLmuIMQNJPvQj9Qn5uHrAQY0AQZdMQwU09neueZ Er7L+uqDYsgpswyDZWUObSxlw5nCvasUXwW6XNX1aFGsY4mGxP8wme1JQyb3LP9Z9Yv+ vcbA== X-Gm-Message-State: AOAM530KRbxr+daPllVO/i+58dxMP95K6dIIZnUYEmA9j54+jSpfPqHX u2BPOkyKmsK1KeNVuvmFaorrSA== X-Google-Smtp-Source: ABdhPJzk66KFeaA/W7QrLprNywnxCNuGGLYvbuTssZAI082qfxCKsu+Dbl7ZuXAlTeMe+UC5pi2jfQ== X-Received: by 2002:a50:af21:: with SMTP id g30mr22961946edd.46.1604439584797; Tue, 03 Nov 2020 13:39:44 -0800 (PST) Received: from localhost (ip-86-49-245-76.net.upcbroadband.cz. [86.49.245.76]) by smtp.gmail.com with ESMTPSA id k4sm64344edq.73.2020.11.03.13.39.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 13:39:43 -0800 (PST) Date: Tue, 3 Nov 2020 22:39:42 +0100 From: Tomas Vondra To: James Coleman Cc: Jaime Casanova , Pg Hackers Subject: Re: enable_incremental_sort changes query behavior Message-ID: <20201103213942.sj3qohewdshrw4oz@development> References: <20201029220652.glf4xk2p7wkfisb6@development> <20201030210316.cbwv4arwp4lcfgx2@development> <20201103023743.sswkl6h74dkbcfmp@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20201103023743.sswkl6h74dkbcfmp@development> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Nov 03, 2020 at 03:37:43AM +0100, Tomas Vondra wrote: >On Fri, Oct 30, 2020 at 07:37:33PM -0400, James Coleman wrote: >> >>... >> >>I was looking at this some more, and I'm still convinced that this is >>correct, but I don't think a comment about it being an optimization >>(though I suspect that that its major benefit), since it came from, >>and must parallel, find_ec_member_for_tle, and there is no such >>explanation there. I don't want to backfill reasoning onto that >>decision, but I do think it's important to parallel it since it's >>ultimately what is going to cause errors if we're out of sync with it. >> >>As to why find_em_expr_for_rel is different, I think the answer is >>that it's used by the FDW code, and it seems to me to make sense that >>in that case we'd only send sort conditions to the foreign server if >>the em actually contains rels. >> >>The new series attached includes the primary fix for this issue, the >>additional comments that could either go in at the same time or not, >>and my patch with semi-related questions (which isn't intended to be >>committed, but to keep track of the questions). >> > >Thanks. Attached are two patches that I plan to get committed > >0001 is what you sent, with slightly reworded commit message. This is >the actual fix. > >I'm still thinking about Robert's comment that perhaps we should be >considering only expressions already in the relation's target, which >would imply checking for volatile expressions is not enough. But I've >been unable to convince myself it's correct or incorrect. In any case >0001 is a clear improvement - in the worst case we'll have to make it >stricter in the future. > > >0002 partially reverts ba3e76cc571 by moving find_em_expr_for_rel back >to postgres_fdw.c. We've moved it to equivclass.c so that it could be >called from both the FDW and allpaths.c, but now that the functions >diverged it's only called from the FDW again. So maybe we should move >it back, but I guess that's not a good thing in a minor release. > I've pushed the 0001 part, i.e. the main fix. Not sure about the other parts (comments and moving the code back to postgres_fdw) yet. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services