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 1mvTBz-0004pR-2q for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Dec 2021 23:51:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mvTBx-0006G4-Ie for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Dec 2021 23:51:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mvTBx-0006Fv-6D for pgsql-hackers@lists.postgresql.org; Thu, 09 Dec 2021 23:51:13 +0000 Received: from mxout2.routing.net ([2a03:2900:1:a::b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mvTBu-0005dA-Dq for pgsql-hackers@postgresql.org; Thu, 09 Dec 2021 23:51:12 +0000 Received: from mxbox4.masterlogin.de (unknown [192.168.10.79]) by mxout2.routing.net (Postfix) with ESMTP id C6D595FBBE; Thu, 9 Dec 2021 23:51:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1639093867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EYqugOQDTxu6+Aops6ADKcJcvs/qYPcjaLF2L5MIF6w=; b=iDsfMWoAATGoXel5n6fBd7FSH5ekmnUE0LhwBonx039wB4AgXc2Gtwfn74Fei7LrgilPUW wovLWYc+jk9UIPUjSmvlruJVFy10CJBMm6W5h9JGmSvS3Nxp8l7UBQpRAvz3crZWnp1FJ0 2xhi2obsil7x7WI+OavnT7bImGtrMUs= Received: from remote.index.de (i68970D96.versanet.de [104.151.13.150]) by mxbox4.masterlogin.de (Postfix) with ESMTPSA id 63476801A1; Thu, 9 Dec 2021 23:51:07 +0000 (UTC) Received: from acedia.index-gruppe.local (192.168.54.121) by invidia.index-gruppe.local (192.168.54.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Fri, 10 Dec 2021 00:51:04 +0100 Received: from acedia.index-gruppe.local ([fe80::a445:8e8f:dbeb:13de]) by acedia.index-gruppe.local ([fe80::a445:8e8f:dbeb:13de%13]) with mapi id 15.01.2308.020; Fri, 10 Dec 2021 00:51:03 +0100 From: Arne Roland To: Tomas Vondra CC: pgsql-hackers Subject: Re: PATCH: generate fractional cheapest paths in generate_orderedappend_path Thread-Topic: PATCH: generate fractional cheapest paths in generate_orderedappend_path Thread-Index: AQHXMxwFBSWPrfL6EUqWBkKfzekca6rGmsgBgDwx81n///NcAIAALGoAgAAAZwCAAAGEAIAASqAYgCOeUZuA+duYRIAARBQAgAqYO8s= Date: Thu, 9 Dec 2021 23:51:02 +0000 Message-ID: <0a472445febe4886b629a71aa70de1a9@index.de> References: , In-Reply-To: Accept-Language: en-US, de-DE Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.255.1.33] Content-Type: multipart/alternative; boundary="_000_0a472445febe4886b629a71aa70de1a9indexde_" MIME-Version: 1.0 X-Mail-ID: 2c1e3e31-df3a-4cb4-8b53-538b3cfcee70 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --_000_0a472445febe4886b629a71aa70de1a9indexde_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, thanks for the reply! From: Tomas Vondra Sent: Thursday, December 2, 2021 20:58 Subject: Re: PATCH: generate fractional cheapest paths in generate_ordereda= ppend_path > [...] > Well, I mentioned three open questions in my first message, and I don't > think we've really addressed them yet. We've agreed we don't need to add > the incremental sort here, but that leaves > > > 1) If get_cheapest_fractional_path_for_pathkeys returns NULL, should we > default to cheapest_startup or cheapest_total? I think it's reasonable to use cheapest_total like we are doing now. I hard= ly see any reason to change it. The incremental sort case you mentioned, seems like the only case that plan= might be interesting. If we really want that to happen, we probably should= check for that separately, i.e. having startup_fractional. Even though thi= s is a fairly special case as it's mostly relevant for partitionwise joins,= I'm still not convinced it's worth the cpu cycles. The point is that in mo= st cases factional and startup_fractional will be the same anyways. And I suspect, even if they aren't, solving that from an application develo= pers point of view, is in most cases not that difficult. One can usually ma= tch the pathkey. I personally had a lot of real world issues with missing f= ractional paths using primary keys. I think it's worth noting that everythi= ng will likely match the partition keys anyways, because otherwise there is= no chance of doing a merge append. If I am not mistaken, in case we end up doing a full sort, the cheapest_tot= al path should be completely sufficient. > 2) Should get_cheapest_fractional_path_for_pathkeys worry about > require_parallel_safe? I think yes, but we need to update the patch. I admit, that such a version of get_cheapest_fractional_path_for_pathkeys c= ould be consistent with other functions. And I was confused about that befo= re. But I am not sure what to use require_parallel_safe for. build_minmax_p= ath doesn't care, they are never parallel safe. And afaict generate_ordered= append_paths cares neither, it considers all plans. For instance when it ca= lls get_cheapest_path_for_pathkeys, it sets require_parallel_safe just to f= alse as well. > I'll take a closer look next week, once I get home from NYC, and I'll > submit an improved version for the January CF. Thank you for your work! The current patch, apart from the comments/regress= ion tests, seems pretty reasonable to me. Regards Arne --_000_0a472445febe4886b629a71aa70de1a9indexde_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi,

thanks for the reply!

From: Tomas Vondra <tomas.vondra@enterprisedb.com>
Sent: Thursday, December 2, 2021 20:58
Subject: Re: PATCH: generate fractional cheapest paths in generate_ordereda= ppend_path
> [...]
> Well, I mentioned three open questions in my first message, and I don'= t
> think we've really addressed them yet. We've agreed we don't need to a= dd
> the incremental sort here, but that leaves
>
>
> 1) If get_cheapest_fractional_path_for_pathkeys returns NULL, should w= e
> default to cheapest_startup or cheapest_total?

I think it's reasonable to use cheapest_total like we are doing now. I hard= ly see any reason to change it.
The incremental sort case you mentioned, seems like the only case that plan= might be interesting. If we really want that to happen, we probably should= check for that separately, i.e. having startup_fractional. Even though thi= s is a fairly special case as it's mostly relevant for partitionwise joins, I'm still not convinced it's wort= h the cpu cycles. The point is that in most cases factional and startup_fra= ctional will be the same anyways.
And I suspect, even if they aren't, solving that from an application develo= pers point of view, is in most cases not that difficult. One can usually ma= tch the pathkey. I personally had a lot of real world issues with missing f= ractional paths using primary keys. I think it's worth noting that everything will likely match the partition = keys anyways, because otherwise there is no chance of doing a merge append.=
If I am not mistaken, in case we end up doing a full sort, the cheapest_tot= al path should be completely sufficient.

> 2) Should get_cheapest_fractional_path_for_pathkeys worry about
> require_parallel_safe? I think yes, but we need to update the patch.
I admit, that such a version of get_cheapest_fractional_path_for_pathkeys c= ould be consistent with other functions. And I was confused about that befo= re. But I am not sure what to use require_parallel_safe for. build_minmax_p= ath doesn't care, they are never parallel safe. And afaict generate_orderedappend_paths cares neither, it c= onsiders all plans. For instance when it calls get_cheapest_path_for_pathke= ys, it sets require_parallel_safe just to false as well.

> I'll take a closer look next week, once I get home from NYC, and I'll<= br> > submit an improved version for the January CF.

Thank you for your work! The current patch, apart from the com= ments/regression tests, seems pretty reasonable to me.

Regards
Arne

--_000_0a472445febe4886b629a71aa70de1a9indexde_--