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 1sm1UC-002ekW-Ej for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Sep 2024 01:40:36 +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 1sm1UA-000j1Z-RU for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Sep 2024 01:40:35 +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 1sm1UA-000j1Q-GL for pgsql-hackers@lists.postgresql.org; Thu, 05 Sep 2024 01:40:34 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sm1U8-000D3P-Py for pgsql-hackers@postgresql.org; Thu, 05 Sep 2024 01:40:34 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-53653682246so63750e87.1 for ; Wed, 04 Sep 2024 18:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725500431; x=1726105231; darn=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=nTeeotbNcnHoO68TU3K7Pb4i9Bg7+Te0Su5CtotSR4g=; b=ZV/+VfJCW8Vs9BYtKcLC4e2GDX/Ryuit8FVYHpxYONcfDpPah5MxKFEOh6H5DtazKY SPlDdnbpYQpH/lT/GtznrTDfvtWebu+15o56DoLVzfhVuywtnIUDenfHrtWdjzw6NZsz 9FTDzAYnX5hhk0S/P+LT+Vhp+SXRNbmb43OiZucn4zGsMoKDFGMfG0ahm3qHRiFXuNPR ak2ZDWzoz0fSjR0OlCunIRZQvqXWX4t3OC6SOH1IJKxeXL0VW8xy0kMNk4L1rzYqv5IL UcUdObo43JegliqakxQwleTXSqUTu7Q94/B/OigvaKoSNFws8+vPYBfaDW6zISbhiU94 JQiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725500431; x=1726105231; 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=nTeeotbNcnHoO68TU3K7Pb4i9Bg7+Te0Su5CtotSR4g=; b=qDYzRLlsmWOMwMT8bQfNlm/AvpCKgbiU+fTCjEiEPMHiylnbxThNis/Dqes7xP6woR Vj/FWubheamxPD/qEaWDDkyLIEujeSqjqoRApvJxU7x6Jjxy59dDb1iAM3rFelr+5qDO gETFNAkKuhzW2OsLALO6MNSSiCGn66IdMh3grBTVQUlIuQvg18tHLajG6qXxOIbkBYBn yRJre3EDTUPKxFyEcDPqH8QQZRxLfzIsJYd5udRx2yzK2xi8VGhdNDy98RtgkYvody2H G21ljzW+K2IMkrQAbh1cECo/EgQpUWXn+DptRyfzSh6ZlF6xiV8yGHfGaqsR8y4yq3nJ zDzg== X-Forwarded-Encrypted: i=1; AJvYcCUP1w/11JCR4kVk0yOovirAsAG2vJbDM4u/0neoYeoIFb2Ws4hN6tbgk2mA0byNLUHGnI6nGDvk8O5E+VKv@postgresql.org X-Gm-Message-State: AOJu0YyA30gb06ZzqEXWyUcPDzgDjmnqzZ8jgD/kpOpz7faacJiXBpoP gP29Xgfs+T0QBVZ+fK5h7wmhppLgK+xfRA5rIh7N6XdZFUylduXTG8GDUVAYOzyG8NDuZEEmdg2 9D/GN59Sqm/7SIMfp7IoC518raxI= X-Google-Smtp-Source: AGHT+IHGP/j9uz4yr+vuGKsC4u9XTYPXVm63w6TzrT5yxx+GmMqZ7lhOzZhAdng4BT2ejSZtUcLCI20ig3pP5InpcH4= X-Received: by 2002:a05:6512:15a3:b0:52c:dc6f:75a3 with SMTP id 2adb3069b0e04-53546b8dd2dmr13709858e87.40.1725500430199; Wed, 04 Sep 2024 18:40:30 -0700 (PDT) MIME-Version: 1.0 References: <87il22cj51.fsf@163.com> In-Reply-To: From: Tender Wang Date: Thu, 5 Sep 2024 09:40:18 +0800 Message-ID: Subject: Re: Eager aggregation, take 3 To: Richard Guo Cc: Paul George , Andy Fan , PostgreSQL-development , pgsql-hackers@lists.postgresql.org, Robert Haas Content-Type: multipart/alternative; boundary="00000000000033b55b0621556026" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000033b55b0621556026 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Richard Guo =E4=BA=8E2024=E5=B9=B48=E6=9C=8821=E6= =97=A5=E5=91=A8=E4=B8=89 15:11=E5=86=99=E9=81=93=EF=BC=9A > On Fri, Aug 16, 2024 at 4:14=E2=80=AFPM Richard Guo > wrote: > > I had a self-review of this patchset and made some refactoring, > > especially to the function that creates the RelAggInfo structure for a > > given relation. While there were no major changes, the code should > > now be simpler. > > I found a bug in v10 patchset: when we generate the GROUP BY clauses > for the partial aggregation that is pushed down to a non-aggregated > relation, we may produce a clause with a tleSortGroupRef that > duplicates one already present in the query's groupClause, which would > cause problems. > > Attached is the updated version of the patchset that fixes this bug > and includes further code refactoring. I review the v11 patch set, and here are a few of my thoughts: 1. in setup_eager_aggregation(), before calling create_agg_clause_infos(), it does some checks if eager aggregation is available. Can we move those checks into a function, for example, can_eager_agg(), like can_partial_agg() does? 2. I found that outside of joinrel.c we all use IS_DUMMY_REL, but in joinrel.c, Tom always uses is_dummy_rel(). Other commiters use IS_DUMMY_REL. 3. The attached patch does not consider FDW when creating a path for grouped_rel or grouped_join. Do we need to think about FDW? I haven't finished reviewing the patch set. I will continue to learn this feature. --=20 Thanks, Tender Wang --00000000000033b55b0621556026 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
Richard Guo <guofenglinux@gmail.com> =E4=BA=8E2024=E5=B9=B48= =E6=9C=8821=E6=97=A5=E5=91=A8=E4=B8=89 15:11=E5=86=99=E9=81=93=EF=BC=9A
=
On Fri, Aug 16, 202= 4 at 4:14=E2=80=AFPM Richard Guo <guofenglinux@gmail.com> wrote:
> I had a self-review of this patchset and made some refactoring,
> especially to the function that creates the RelAggInfo structure for a=
> given relation.=C2=A0 While there were no major changes, the code shou= ld
> now be simpler.

I found a bug in v10 patchset: when we generate the GROUP BY clauses
for the partial aggregation that is pushed down to a non-aggregated
relation, we may produce a clause with a tleSortGroupRef that
duplicates one already present in the query's groupClause, which would<= br> cause problems.

Attached is the updated version of the patchset that fixes this bug
and includes further code refactoring.

=C2= =A0I review the v11 patch set, and here are a few of my thoughts:
=C2=A0
1.=C2=A0 in setup_eager_aggregation(), before calli= ng create_agg_clause_infos(), it does
some checks if eager aggreg= ation is available. Can we move those checks into a function,
for= example, can_eager_agg(), like can_partial_agg() does?

2.=C2=A0 I found that outside of joinrel.c we all use IS_DUMMY_REL,= =C2=A0 but in joinrel.c, Tom always uses
is_dummy_rel(). Other co= mmiters use IS_DUMMY_REL.=C2=A0

3.=C2=A0 The attac= hed patch does not consider FDW when creating a path for grouped_rel or gro= uped_join.
Do we need to think about FDW?

I haven't finished reviewing the patch set. I will continue to learn = this feature.

--=
Thanks,
Tender Wang
--00000000000033b55b0621556026--