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 1stM3I-00FZRe-9v for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Sep 2024 07:03:08 +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 1stM3H-004Umx-Jv for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Sep 2024 07:03:07 +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 1stM3H-004Umo-AF for pgsql-hackers@lists.postgresql.org; Wed, 25 Sep 2024 07:03:07 +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 1stM3D-000yjZ-47 for pgsql-hackers@lists.postgresql.org; Wed, 25 Sep 2024 07:03:06 +0000 Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-6db4b602e38so51681077b3.1 for ; Wed, 25 Sep 2024 00:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727247783; x=1727852583; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=D0wclFFnKdDZL6SxzTfyJZJ+DoXoprEH1vu9Kz2hvNQ=; b=mhcTk27oymdgMHzTxbC1GwMIltjavL5fUNdKdipBCCMKTHXu1P8tNrcuk/ROejZVRq 5WfP0NSsicG9BVlcd93xzKVFmeT37FvX7GPl6mL9z6yx8PjhLvYNKkqOrtsQYV5Dm83S n0MddmKfn4In9kxC/o9bCr2eTbevNEJejYgBhviJWNI2IgDo9+b4PSJG1Z0wJb9TjO6R S2uC7XQr8PuplEJQ7gVRQv7aQp/auLh5fTrN8PFhh65PLAD7ixBBDNo+J0VK6yzNTP4/ etTRexWvD9ydJaY3XNPblWsnMDlV/FteKtNIfuAZU9xpLxRx9K8FKqaKeZbfSBjUZZxh AWGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727247783; x=1727852583; h=content-transfer-encoding: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=D0wclFFnKdDZL6SxzTfyJZJ+DoXoprEH1vu9Kz2hvNQ=; b=cVG4RPfZylyWwh/Et9EdqEq2K71jzzJjJ8HDnFXpiQfHJRvaePF+ldz52VYGkh5g1w bfuoc1Duxw6jozW2MpdpRCcsNpF1CvSN+v4HMP68rnuslA6IRisFXcHMVDQr5FRysSv+ AG9gz+ENzil7CvLSRx5OKkrDvXnLyxeWORctn8S882MF2efuSVow02KoG4wXz5BIchpx usdEaRQ1misA+cSfUwr2BQgBkEQrnVUDmpkXcAoE8F3RsiWzkbgMuYSGqt45fh8QIpoJ 5qtmPmBasMIMSxamG4nwiLBQzxFtix95OnyvQkbWkAI2DgVWDdoJIJ+eAzhKoLhRRgcc HaFQ== X-Forwarded-Encrypted: i=1; AJvYcCUapYeU3i7qBiOoRGy+Si66/NhvPVLiEaYDgTm3sIemvOezAk2xRI5mhc7AmWx3rorJfAHpC9utNA7ZlGEk@lists.postgresql.org X-Gm-Message-State: AOJu0YyFHeaH1Hfx31YP24hyi4ZdA9BD5n2nOgHCvqgZNWt218HmEehu f2RFP4vtwa9bqNkLklGILdo3A6CFrlLBCue7NbnIVyE/pp70ULAjVYDFHKTV5ioM+/BvVDcyRwo 0oCkPdftlP8zflOJNeR/USDO48mU= X-Google-Smtp-Source: AGHT+IGfZaF/PEZ/fI29tbJYx/QLxOtMa8OMUIme1rkinqm43MRWWJRAdZKs7vSW1E905bqPaS7CmRtzS7fKvFxTaOo= X-Received: by 2002:a05:690c:67c3:b0:6d3:e798:a1e1 with SMTP id 00721157ae682-6e21da62c98mr14936867b3.40.1727247782801; Wed, 25 Sep 2024 00:03:02 -0700 (PDT) MIME-Version: 1.0 References: <87il22cj51.fsf@163.com> In-Reply-To: From: Richard Guo Date: Wed, 25 Sep 2024 15:02:51 +0800 Message-ID: Subject: Re: Eager aggregation, take 3 To: Tender Wang Cc: Paul George , Andy Fan , PostgreSQL-development , pgsql-hackers@lists.postgresql.org, Robert Haas Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Sep 11, 2024 at 10:52=E2=80=AFAM Tender Wang w= rote: > 1. In make_one_rel(), we have the below codes: > /* > * Build grouped base relations for each base rel if possible. > */ > setup_base_grouped_rels(root); > > As far as I know, each base rel only has one grouped base relation, if po= ssible. > The comments may be changed to "Build a grouped base relation for each ba= se rel if possible." Yeah, each base rel has only one grouped rel. However, there is a comment nearby stating 'consider_parallel flags for each base rel', which confuses me about whether it should be singular or plural in this context. Perhaps someone more proficient in English could clarify this. > 2. According to the comments of generate_grouped_paths(), we may generat= e paths for a grouped > relation on top of paths of join relation. So the =E2=80=9Drel_plain" arg= ument in generate_grouped_paths() may be > confused. "plain" usually means "base rel" . How about Re-naming rel_plai= n to input_rel? I don't think 'plain relation' necessarily means 'base relation'. In this context I think it can mean 'non-grouped relation'. But maybe I'm wrong. > 3. In create_partial_grouping_paths(), The partially_grouped_rel could ha= ve been already created due to eager > aggregation. If partially_grouped_rel exists, its reltarget has been cre= ated. So do we need below logic? > > /* > * Build target list for partial aggregate paths. These paths cannot just > * emit the same tlist as regular aggregate paths, because (1) we must > * include Vars and Aggrefs needed in HAVING, which might not appear in > * the result tlist, and (2) the Aggrefs must be set in partial mode. > */ > partially_grouped_rel->reltarget =3D > make_partial_grouping_target(root, grouped_rel->reltarget, > extra->havingQual= ); Yeah, maybe we can avoid building the target list here for partially_grouped_rel that is generated by eager aggregation. Thanks Richard