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 1v6S8J-004s1O-IO for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Oct 2025 11:14:59 +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 1v6S8F-009SLz-EZ for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Oct 2025 11:14: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 1v6S8F-009SLq-1V for pgsql-hackers@lists.postgresql.org; Wed, 08 Oct 2025 11:14:56 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v6S8D-0011bO-1P for pgsql-hackers@postgresql.org; Wed, 08 Oct 2025 11:14:55 +0000 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-37612b15a53so4069561fa.1 for ; Wed, 08 Oct 2025 04:14:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759922092; x=1760526892; darn=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=Fu5YwN3t3tDwLRPw6+QsEQnm0nPr9BwaV5pNKOjkq80=; b=MQ0cOLri00h/fs2+fboePDG9YCofaUH8iaXYr1mAvE+ahYkkNbkdsE11//vfB6+Rxr 5gx1RSN0BQ2kuHCiB2Sn9x7C2Rdfcu/lkq6roOGkzE6jUbHB+4Kx19RAbmpvJ0NmDjrr V5R4TlFuilCaeQDPE1ULTta1FZEwJBN/A8k3rIBHEcZPFrmBnIGKJ7ui6xX4V95UYZU1 AOV3dopmw7qHeUWhiCyoZhgFJbjOZrw6ZxPygx5/0Cc2lR0RK9XIx6EGUN2KzahfzwFt xEiumBwKSIq5PqydQNsU2pDIQIlB7uR16MDovKuhmpOR+oGWqXtMOwJil8p8AOV9RGDs mALQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759922092; x=1760526892; 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=Fu5YwN3t3tDwLRPw6+QsEQnm0nPr9BwaV5pNKOjkq80=; b=vB6vcDbhQ++ipBN5huBsRMNwIor3srTTgI0rXAVPISSCRse2X9knUzBewGYWegf6Ob NN151FFeYQo8034eAJxpPYSZkGXWy2l9Jo4NHDBKvqPTTReIcM+dd8QhMQHA41qlCV8e g1gvWDYPOBgGNvPbICSRnBmYwYVnGsac5DVgUM00LkldhzIWdYnjVeel8Z5QhbxJqYc1 aUva4PXx4hwnJg2HDg6z7FztiPKGqylZWDRuyZThJxqSQiHWsyZsv5A8CtoTpNBt8+fR mPS7DS22ETnz+Ik0ljiC9FzTv5t4SorCZZW5pYVgBaNK9q/rn3lQGfGExUOWzlc0PKTj hUlw== X-Forwarded-Encrypted: i=1; AJvYcCXn2txhn7pvwrpN/IP8NhYa5Q8fawLs3n0Hf712x+gRw8aYqf7BBCF8zuJsXV1tYVVE8mhO3LxiblRZOg9/@postgresql.org X-Gm-Message-State: AOJu0YyffD2mEWryBozralrXNT0uBhnwhUSf15kghvT4jVKYRBF0JKRC 79nwLegpz5PC7hZgyUrhpyCLRHJV46X2odikySc/3BcxEODhHoU2sXNLiNUXNuQXqWFo94gMeF2 3itHGU7r1WUAv9jzPSE0AHCRBKXUclFA= X-Gm-Gg: ASbGncsoIMa3HD2erGCFoeqIL9eBDhQ+0MM8F/zu9ayx2MWHrJvG5EBYCNrkufF8PzA OvYjfpW8hPCFb59xcuugdGA2/HZxNmjE6eaWJOvPn3RWZLYEi2NcSC/0d5RYAnROFTXo0qBWiQm /TiGROnz03J5ALUwp7Zhgm4furkPnJTfHRyEm+Yn+ROOeimlGKm7gjjck95Vc4k3AbgXTLeNBHo vXJWoYsUoM0HdcndoK781hbmFWozKdj3YNeQwYc9WiGc1jgTTHCGuIB+1N4+gCgswaKq0LLXu8k G7ZZpiEBpD7jabFXKiK7kP+N0lQqivLx X-Google-Smtp-Source: AGHT+IEYSKxQ+TSnEgRCWPEJ+EavYDl0BqGuC3XZS1yVkVXRYJJnwcm3s2DFQBc1Ml7NyxuxO3VUaM3rDFshzoW6qQQ= X-Received: by 2002:a2e:be24:0:b0:338:1daf:f192 with SMTP id 38308e7fff4ca-37609e4932emr8257731fa.28.1759922091702; Wed, 08 Oct 2025 04:14:51 -0700 (PDT) MIME-Version: 1.0 References: <87il22cj51.fsf@163.com> In-Reply-To: From: David Rowley Date: Thu, 9 Oct 2025 00:14:39 +1300 X-Gm-Features: AS18NWB7YtUl9R7JLAEqVUvd65a8fuSag7_fIbBmCfCDuE8TSAcImomTg_5gBCc Message-ID: Subject: Re: Eager aggregation, take 3 To: Richard Guo Cc: Robert Haas , Tom Lane , Tender Wang , Paul George , Andy Fan , PostgreSQL-development , pgsql-hackers@lists.postgresql.org, Matheus Alcantara 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 Tue, 7 Oct 2025 at 23:57, Richard Guo wrote: > > On Mon, Oct 6, 2025 at 10:59=E2=80=AFPM David Rowley wrote: > > 6. Shouldn't this be using lappend()? > > > > agg_clause_list =3D list_append_unique(agg_clause_list, ac_info); > > > > I don't understand why ac_info could already be in the list. You've > > just done: ac_info =3D makeNode(AggClauseInfo); > > A query can specify the same Aggref expressions multiple times in the > target list. Using lappend here can lead to duplicate partial Aggref > nodes in the targetlist of a grouped path, which is what I want to > avoid. I was getting that mixed up with list_append_unique_ptr(). > > 9. In get_expression_sortgroupref(), a comment claims "We ignore child > > members here.". I think that's outdated since ec_members no longer has > > child members. > > I think that comment is used to explain why we only scan ec_members > here. Similar comments can be found in many other places, such as in > equivclass.c: > > /* > * Found our match. Scan the other EC members and attempt to generate > * joinclauses. Ignore children here. > */ > foreach(lc2, cur_ec->ec_members) > { I'd say that's also wrong. "Ignore" means not to pay attention to something that's there. The child members are not there. > > 11. The way you've written the header comments for typedef struct > > RelAggInfo seems weird. I've only ever seen extra details in the > > header comment when the inline comments have been kept to a single > > line. You're spanning multiple lines, so why have the out of line > > comments in the header at all? > I've also updated the comments within RelAggInfo to use one-line > style. The style I'd thought of had the comments on the same line as the field. Something like struct EquivalenceClass. >I wrapped the long queries in v24. +-- Enable eager aggregation, which by default is disabled. +SET enable_eager_aggregate TO on; The above comment and command mismatch to my understanding from looking at postgresql.conf.sample and guc_parameters.dat. David