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 1kOTY7-00022F-2b for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Oct 2020 22:29:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kOTY4-0006JN-KJ for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Oct 2020 22:29:08 +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 1kOTY4-0006JG-9f for pgsql-hackers@lists.postgresql.org; Fri, 02 Oct 2020 22:29:08 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kOTXx-0004ek-Hd for pgsql-hackers@postgresql.org; Fri, 02 Oct 2020 22:29:07 +0000 Received: by mail-wr1-x443.google.com with SMTP id s12so3333601wrw.11 for ; Fri, 02 Oct 2020 15:29:01 -0700 (PDT) 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=Y79VvNjhs+UdP0DXaBX54uZLEeBZrFwmdBCnHE/qYeQ=; b=KoazdpTs0DNmQ7VHu4C5hQy3dztmyjGMMX1JaTlUjCxHDjMzg+lhGau++Cx/AlyXnp GkvHWeC5lLwRobSx+NfGCj8K3WQG317i9kpKQbSJwFn50WJCpb+9VodbB5F3mcmPH9FP dn+7yEInpHKvuO8mMuYvdLJRuTmhu0sapmVBMeXSyHhl3ogWIDMuDjuO32oOyynv5caw qFfkt99QDlPJDGWQHs8ZEizZAKjDSqgvSof9Ke5DgAVUvLP7MNZTHWQrzwyqZEFfQJIu AfG5jVscO7NLNSOZ/1tGqqHPo3/V2KJVduIzQoSSEMKEnL7GAiQ5AffaJrFPaUclVzfB bRxg== 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=Y79VvNjhs+UdP0DXaBX54uZLEeBZrFwmdBCnHE/qYeQ=; b=jX9iSuWHEbz2+Q5sIgU2evLA99MZzCjTRQGe640/7cTFqL8GNz2NDqehQ+WhJ+V9yU vl+mAf+GwuXBXMg8/28T+1PrSTVgQdyuDZIBdnZAZ0ktZeistFdcT519whhv1OYQjp75 Z3MwS9y9M4GRroKiJPxDk7fCWzh/yBmHaCcKM2tLxLsICV1U4O+Z4TtlJt+Z01odb340 P4om6b0A8fZUKdEk2h+JSmyxEik9OutPuDm4VNnZGv9V93DzMaskXjQgYSvIgDD9CFA0 tHQgfJlZVy4XxZOSWUq5YtB36KkExPkGaH+EEq33Bxig7ybfhxrnhBa/uS4wKXv70OPT M8aA== X-Gm-Message-State: AOAM531hA1qaeaVSfZwCKZLmwptM+Z1Y/YM14USpkHYdoR8dC7q7hg6M L9AN91Ua6lDJCQnBKWBnOYIt5Q== X-Google-Smtp-Source: ABdhPJxjATolqzn2osSmTmPt0ci9UtPjrJfGbUod7QjyHsQ1K1Oaj8N6JOI3U2Npeq/DOcn9kC1xlw== X-Received: by 2002:a5d:4c86:: with SMTP id z6mr5047560wrs.23.1601677739031; Fri, 02 Oct 2020 15:28:59 -0700 (PDT) Received: from localhost (ip-86-49-245-76.net.upcbroadband.cz. [86.49.245.76]) by smtp.gmail.com with ESMTPSA id d13sm3102989wrp.44.2020.10.02.15.28.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2020 15:28:58 -0700 (PDT) Date: Sat, 3 Oct 2020 00:28:57 +0200 From: Tomas Vondra To: James Coleman Cc: Jaime Casanova , Pg Hackers Subject: Re: enable_incremental_sort changes query behavior Message-ID: <20201002222857.t3sijcldxcdt2d6d@development> References: <20201001220822.rwwxajwzobljgqwz@development> <20201002143207.qt7re34mhsfmfi6f@development> <20201002182508.cbux56rfoak2jzdf@development> <20201002205620.sbmfqdmkprjrlpgz@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Oct 02, 2020 at 05:45:52PM -0400, James Coleman wrote: >On Fri, Oct 2, 2020 at 4:56 PM Tomas Vondra > wrote: >> >> ... >> >> More importanly, it does not actually fix the issue - it does fix that >> particular query, but just replacing the DISTINCT with either ORDER BY >> or GROUP BY make it fail again :-( >> >> Attached is a simple script I used, demonstrating these issues for the >> three cases that expect to have ressortgroupref != 0 (per the comment >> before TargetEntry in plannodes.h). > >So does checking for volatile expressions (if you happened to test >that) solve all the cases? If you haven't tested that yet, I can try >to do that this evening. > Yes, it does fix all the three queries in the SQL script. The question however is whether this is the root issue, and whether it's the right way to fix it. For example - volatility is not the only reason that may block qual pushdown. If you look at qual_is_pushdown_safe, it also blocks pushdown of leaky functions in security_barrier views. So I wonder if that could cause failures too, somehow. But I haven't managed to create such example. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services