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 1iELLg-0004X1-Cl for pgsql-hackers@arkaria.postgresql.org; Sat, 28 Sep 2019 22:37:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iELLe-00024Z-Vl for pgsql-hackers@arkaria.postgresql.org; Sat, 28 Sep 2019 22:37:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iELLe-000243-K4 for pgsql-hackers@lists.postgresql.org; Sat, 28 Sep 2019 22:37:54 +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 1iELLX-0006zA-HU for pgsql-hackers@postgresql.org; Sat, 28 Sep 2019 22:37:53 +0000 Received: by mail-wr1-x443.google.com with SMTP id b9so6923023wrs.0 for ; Sat, 28 Sep 2019 15:37:47 -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=4ZjAA7hmbO/j84+oS35GJG79By2YNWuhCA8XEKduNCs=; b=TecWBIUc72Lc2Fx3ggKBzZXQ0n97RP9GtfuHa1fA65MN1iJHOwHroD2uVVNJnoB73+ tiKtnKppktpDDAyRUDW2on214c62CIaBtwcT89etwrTUwia+5Z5NSL720CoyEt70ffSc Zv8uSOecV9UT91GErULQ7Bw9rAm4ghfaqRN/L46OAOJ+sOTIKpt9ehiUuU7e1XgzzWUs 1tu4Ldr/gSDFI1mp8W7f8YjPF9IvX56LYNI3UkcNz/nsUjPB89FEyZOdhEWdWV1VRlmG aBl7iMs28Mtyd1HQdsjQKk1vQtMtoQe08xlLoa8yPEKzUzfo5d4tUqM/vkyg7Qx4/MTp TPdg== 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=4ZjAA7hmbO/j84+oS35GJG79By2YNWuhCA8XEKduNCs=; b=kpsRHhZgSfGzWlF3OR22pRkv/7H9i/9jWZ7kfxmjTp9cXLUK8M99/TZCCHKcW3UIZ2 bQkW7NfCgCEAlrgR392GP8eGI4FZqj/7giTDvN/KTR1Vcz89qtYUfpI9GRMChNwmfZ1K KIgQNZglvd8PPdKxaw5A6bmbIzsgB3uPQe6CZdKh1+K3rxtCFbDZhcVqchGKTejHeqP3 6463gBysGOx4bfO0Z63DSUDJTTezHJM+Hi0cjHT2csi27IGIx96vtIOmidqJ6GTJEF3S fZRAIJYlxmI80Sro9pSXSPs8GQjrWa1m/CyWsH6eT3nKrH1G9yLomptmagU2ixt4ucEf fWxw== X-Gm-Message-State: APjAAAUFOxjgLa2YkL6OKjtXZ5BPvOqQi1NVBEkFeg59zsn8j41VFycN D2W8DwQJy38Y9nDVa94FJkI/UA== X-Google-Smtp-Source: APXvYqzGV+a+O1PQt+FHRGJrQOWq3Ii0/Ax2jE3iEcMEmG/kajF/mD/0xV6eAQd0gD4AiqZrd4O/UA== X-Received: by 2002:adf:eb42:: with SMTP id u2mr7655510wrn.307.1569710266056; Sat, 28 Sep 2019 15:37:46 -0700 (PDT) Received: from localhost (ip-86-49-253-183.net.upcbroadband.cz. [86.49.253.183]) by smtp.gmail.com with ESMTPSA id c132sm9561215wme.27.2019.09.28.15.37.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2019 15:37:43 -0700 (PDT) Date: Sun, 29 Sep 2019 00:37:41 +0200 From: Tomas Vondra To: Robert Haas Cc: James Coleman , pgsql-hackers Subject: Re: Consider low startup cost in add_partial_path Message-ID: <20190928223741.fllqcjhpv2zdbljr@development> References: 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 Sat, Sep 28, 2019 at 12:16:05AM -0400, Robert Haas wrote: >On Fri, Sep 27, 2019 at 2:24 PM James Coleman wrote: >> Over in the incremental sort patch discussion we found [1] a case >> where a higher cost plan ends up being chosen because a low startup >> cost partial path is ignored in favor of a lower total cost partial >> path and a limit is a applied on top of that which would normal favor >> the lower startup cost plan. >> >> 45be99f8cd5d606086e0a458c9c72910ba8a613d originally added >> `add_partial_path` with the comment: >> >> > Neither do we need to consider startup costs: >> > parallelism is only used for plans that will be run to completion. >> > Therefore, this routine is much simpler than add_path: it needs to >> > consider only pathkeys and total cost. >> >> I'm not entirely sure if that is still true or not--I can't easily >> come up with a scenario in which it's not, but I also can't come up >> with an inherent reason why such a scenario cannot exist. > >I think I just didn't think carefully about the Limit case. > Thanks! In that case I suggest we treat it as a separate patch/fix, independent of the incremental sort patch. I don't want to bury it in that patch series, it's already pretty large. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services