Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i9oJT-0000Ub-1Z for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Sep 2019 10:32:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i9oJR-00011g-Jw for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Sep 2019 10:32:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i9oJR-00011O-6k for pgsql-hackers@lists.postgresql.org; Mon, 16 Sep 2019 10:32:53 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i9oJN-0006zq-H9 for pgsql-hackers@lists.postgresql.org; Mon, 16 Sep 2019 10:32:52 +0000 Received: by mail-wr1-x441.google.com with SMTP id i18so7594447wru.11 for ; Mon, 16 Sep 2019 03:32:49 -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:user-agent; bh=SpiT8bHMq3bZPFyiwMDF5OyOw+e1zS1t69l41TgJcNU=; b=Ef6OE5HigJL0T485K8jCt7eeDqlMN+dVYXt60GAyo4H/FEi/4hyWJOH7JkuslOvH5o xIeICRm7/uPVAc9+yI9LYjvQImYO8F+Qc9or99gevWaC6bnbdo4GSj5QG3dIpS738w2Z AIprVC5hvJyy05xQtVDZuyqtzgYoLJswWDHVMfV9VMwb+amvOmDErn0pvVau1LiuHsfP Qf1gQth0yLXcxisqTEfrdZ3Y0XuxeWhu3GfZrwSYsKwNS4/2rmuFOCNx0Og4str6ypzm TQYdUg3POruo1w1qAkjOIJYcnpNcKSMgp8HtYV2/OSX0sB7+hlmPOrXhOBCVLgYfG6dy KHZg== 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:user-agent; bh=SpiT8bHMq3bZPFyiwMDF5OyOw+e1zS1t69l41TgJcNU=; b=hFwGp+Z3kqeoD7zvK/qbkC0GSolgmPY5PjmVZQLB5B62GAETciLbOGfrY9rwJI9cF4 9xLXt6qVu1OQnKQWIKBJiijnIGUW/qIySiMmUbmNhYj+jLhLb+K8+LzLGa2ZotkL8jUP E6xV8hdc4ia8PnVwaoaEDL2mdtJef73gaxwlyYE7EcjCzwF6RBnY7xXh8BzPmw5hIcTH cLMGCgDr9BFBLUSrJnC2bGJ6GETc+Tb8YlWmvaBlL20XGbbQa7qfXpBclwQyDx166oap 4UaJ7u3FcVIuFmiFLoWb0N7IieNvSBfR5vuTc+jZSKUY1R/PfeHRP/3ts63M3jkAdNcB E6WA== X-Gm-Message-State: APjAAAUWybaNXju2/kqdn4XwYklymdR3m32cVe0vua/m0QOgPsqOMqn9 9aWFJ32FKFcG7qxEmf9RhmH4mg== X-Google-Smtp-Source: APXvYqxtR+sL73YPRxu8xxBOECwLtI4N+KGIxv/6+8eirPw+YI8Ncr3A0OwckBLDngvcMw5EY4HQzg== X-Received: by 2002:adf:fe07:: with SMTP id n7mr8315847wrr.90.1568629968619; Mon, 16 Sep 2019 03:32:48 -0700 (PDT) Received: from localhost (ip-86-49-253-183.net.upcbroadband.cz. [86.49.253.183]) by smtp.gmail.com with ESMTPSA id e20sm78902617wrc.34.2019.09.16.03.32.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 03:32:45 -0700 (PDT) Date: Mon, 16 Sep 2019 12:32:44 +0200 From: Tomas Vondra To: James Coleman Cc: Peter Geoghegan , Simon Riggs , Rafia Sabih , Shaun Thomas , Dmitry Dolgov <9erthalion6@gmail.com>, Alexander Korotkov , Tom Lane , PostgreSQL Developers Subject: Re: [PATCH] Incremental sort (was: PoC: Partial sort) Message-ID: <20190916103244.eqkifumgacmo6hmc@development> References: <20190708135933.oco3gyloeacdj7yy@development> <20190708145853.x2doaqcyj3enol2e@development> <20190709013703.3mbdhsv2gyxtjc42@development> <20190720132244.3vgg2uynfpxh3me5@development> <20190720152512.jpdi2g3notbjcxsd@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, Sep 15, 2019 at 09:33:33PM -0400, James Coleman wrote: >On Sat, Jul 20, 2019 at 11:25 AM Tomas Vondra > wrote: >> >> ... >> >> >> >> I think this may be a thinko, as this plan demonstrates - but I'm not >> >> sure about it. I wonder if this might be penalizing some other types of >> >> plans (essentially anything with limit + gather). >> >> >> >> Attached is a WIP patch fixing this by considering both startup and >> >> total cost (by calling compare_path_costs_fuzzily). >> > >> >It seems to me that this is likely a bug, and not just a changed >> >needed for this. Do you think it's better addressed in a separate >> >thread? Or retain it as part of this patch for now (and possibly break >> >it out later)? On the other hand, it's entirely possible that someone >> >more familiar with parallel plan limitations could explain why the >> >above comment holds true. That makes me lean towards asking in a new >> >thread. >> > >> >> Maybe. I think creating a separate thread would be useful, provided we >> manage to demonstrate the issue without an incremental sort. > >I did some more thinking about this, and I can't currently come up >with a way to reproduce this issue outside of this patch. It doesn't >seem reasonable to me to assume that there's anything inherent about >this patch that means it's the only way we can end up with a partial >path with a low startup cost we'd want to prefer. > >Part of me wants to pull it over to a separate thread just to get >additional feedback, but I'm not sure how useful that is given we >don't currently have an example case outside of this patch. > Hmm, I see. While I initially suggested to start a separate thread only if we have example not involving an incremental sort, that's probably not a hard requirement. I think it's fine to start a thead briefly explaining the issue, and pointing to incremental sort thread for actual example. > >One thing to note though: the current patch does not also modify >add_partial_path_precheck which also does not take into account >startup cost, so we probably need to update that for completeness's >sake. > Good point. It does indeed seem to make the same assumption about only comparing total cost before calling add_path_precheck. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services