Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qpRPA-005j2J-4m for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Oct 2023 10:53:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qpRP5-005hL9-V2 for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Oct 2023 10:52:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qpRP5-005hL1-Ip for pgsql-hackers@lists.postgresql.org; Sun, 08 Oct 2023 10:52:56 +0000 Received: from mail-yw1-x112f.google.com ([2607:f8b0:4864:20::112f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qpRP1-000ubh-3r for pgsql-hackers@lists.postgresql.org; Sun, 08 Oct 2023 10:52:55 +0000 Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-59f6492b415so31372387b3.0 for ; Sun, 08 Oct 2023 03:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696762369; x=1697367169; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=uEpPBi+PpkFHAkGjdEomt/sA8I4v/ypKB6Tv14PjGTc=; b=fG5QgebBCdgMp+EnuM3vG3pQK4Wd67xIth583wdihZ/RJXOc2BvJRBCUAvkVkXOhI4 ekuGXU6OO+h3Rzk6ArLyPOg3LrfDHecGx4Avsr1U7CHzZ6B8COktF9bM8Iyehe00bpaW kxKZlTvEwaozbVMgnTkUooOzDE27j+2nJtRsYpVALBDI67EL1a4LDAiVSN2+WHsecE5+ jianxqGjVisYV9ZHAK965zmoK67MYmTOD2sg1yhvIkQlHZPoaKXWblMcVXmwJzGNIQx8 xiDo1wuQeqa/WEvnvRrl4GkReOHtGMdjPdrCdSS+fQuZ18QgaCgl+sau+jkO+0NYBeUL I3wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696762369; x=1697367169; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uEpPBi+PpkFHAkGjdEomt/sA8I4v/ypKB6Tv14PjGTc=; b=eVgXxuNEeFdyu+yfcotim2STMu3HcjZrGPD/VJQuozQHtdA/JOeYN4tcPwOytaPRrj HSRhKCg8Xc+jjpR+YB9P3wannjWTRiBMDGTN5Fy6GQJ7WOl/04VM8koaIYpYLjbYS7OR tkPfEnNxXWdjuIaiYEuAFjNfjacVs8lRJj11J/jqjtzRmtCGljNoQ70HUFzju2OTIgwO fas/52Pb2LE/8K8ygdmG1ZE4glH+3ruWV4npP29awO76E3SswpVOIbZWP4Dx1RUfvfGj UwmifpkSmmZA8SyLMRXcTWrb3V+tmDuIYJFXHJlsSoqxGOfXaFzqFF6a+ZSrdNi47ich bGZg== X-Gm-Message-State: AOJu0YxKqtvpkx7YKDC3S6KWIqoht7YU0GHB70dxHvh9e6X9CDL31GgN Bs2s5VEHUEFDS3tRbNF23wg35qHo9Oo0PKGki4M= X-Google-Smtp-Source: AGHT+IE5EPY6zEPPpyoOB4s45boY3iA0BqKt6JzSlPUT/LRmltj4F6BI39FrlExkwqFuThh1kXyomoiCmlU43LDe3B4= X-Received: by 2002:a81:6c95:0:b0:59f:7c4d:33ae with SMTP id h143-20020a816c95000000b0059f7c4d33aemr5081608ywc.21.1696762369316; Sun, 08 Oct 2023 03:52:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Guo Date: Sun, 8 Oct 2023 18:52:38 +0800 Message-ID: Subject: Re: pg16: XX000: could not find pathkey item to sort To: David Rowley Cc: Justin Pryzby , pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000004a9c9d06073246b0" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000004a9c9d06073246b0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Oct 5, 2023 at 2:26=E2=80=AFPM David Rowley = wrote: > So in short, I propose the attached fix without any regression tests > because I feel that any regression test would just mark that there was > a big in create_agg_path() and not really help with ensuring we don't > end up with some similar problem in the future. If the pathkeys that were added by adjust_group_pathkeys_for_groupagg() are computable from the targetlist, it seems that we do not need to trim them off, because prepare_sort_from_pathkeys() will add resjunk target entries for them. But it's also no harm if we trim them off. So I think the patch is a pretty safe fix. +1 to it. > I have some concerns that the assert_pathkeys_in_target() function > might be a little heavyweight for USE_ASSERT_CHECKING builds. So I'm > not proposing to commit that without further discussion. Yeah, it looks like some heavy to call assert_pathkeys_in_target() for each path node. Can we run some benchmarks to see how much overhead it would bring to USE_ASSERT_CHECKING build? Thanks Richard --0000000000004a9c9d06073246b0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Thu, Oct 5, 2023 at 2:26=E2=80=AFPM Da= vid Rowley <dgrowleyml@gmail.com= > wrote:
So in short, I propose the attached fix without any regression tests
because I feel that any regression test would just mark that there was
a big in create_agg_path() and not really help with ensuring we don't end up with some similar problem in the future.

=
If the pathkeys that were added by adjust_group_pathkeys_for_groupagg(= )
are computable from the targetlist, it seems that we do not need to tr= im
them off, because prepare_sort_from_pathkeys() will add resjunk targe= t
entries for them.=C2=A0 But it's also no harm if we trim them off.= =C2=A0 So I
think the patch is a pretty safe fix. =C2=A0+1 to it.
=C2=A0
I have some concerns that the assert_pathkeys_in_target() function
might be a little heavyweight for USE_ASSERT_CHECKING builds. So I'm not proposing to commit that without further discussion.
<= br>
Yeah, it looks like some heavy to call assert_pathkeys_in_tar= get() for
each path node.=C2=A0 Can we run some benchmarks to see how mu= ch overhead it
would bring to USE_ASSERT_CHECKING build?

ThanksRichard
--0000000000004a9c9d06073246b0--