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 1uvuWi-003Uex-FZ for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Sep 2025 09:20:37 +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 1uvuWh-00BBHs-AD for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Sep 2025 09:20:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uvuWg-00BBF6-Sb for pgsql-hackers@lists.postgresql.org; Tue, 09 Sep 2025 09:20:35 +0000 Received: from mail-yx1-xb12a.google.com ([2607:f8b0:4864:20::b12a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uvuWf-001JPh-1L for pgsql-hackers@lists.postgresql.org; Tue, 09 Sep 2025 09:20:34 +0000 Received: by mail-yx1-xb12a.google.com with SMTP id 956f58d0204a3-60296e4926eso1179637d50.1 for ; Tue, 09 Sep 2025 02:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757409632; x=1758014432; 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=UMf9uFdiaYiTcCkL02n3lTDVeLj9pS0KDRYpd31jE94=; b=FJ3nZOzpJqpptNP4A34bEqJMv+Y0aqP/nRCICQDEfEYoOQfS2hnrxKfa6SmSkrLF/M asFSDHMvOhkEiUjnaTVQqXkncS1S6V/zB9lO3WLUJdUHjk1mevmBqOz/U0UerMoElgJp MAGLO5CTkouDvso6O4qijI0xYBlh5akJLY+3WSC4cDLLL6zA4SYfzmxKBtmygu97ISqi +yZNuBbwummTegMX0ZyMJxat3yQrQK1gTvTyYAaphyh7Nofhmo27H4nkFwhslgCVAoCU Ae/liUEH3Da2kIrZl7CyKxNi5GeBtZiE7StLZlUUesv7DLw6jbIm4sjd1gtdPiE5ukI8 JabQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757409632; x=1758014432; 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=UMf9uFdiaYiTcCkL02n3lTDVeLj9pS0KDRYpd31jE94=; b=WuaFcMgrd4mAOsSx7xY/ynBTv0wMhWvZsurXA76H/6N1DfSrA2EUnOFQRjI34Z82tu XlO9c4h6Xiywb5W5+nP6IVXra6WNt79XFS98D1QBcyq5AUrwyboMnXp/i+H7WpKpoJC1 HawMmh+BEfEgsJHJ2ZgUUl5oqAYLFCXCvN+sh+Chr7pOia5pGb9pkNZAzVOkoqsPCNe3 Z7kHIttfRn3MsfB/pQCGKM4WUjImdmoKzGdZ6RAgz8MJuv+EqFWxMXLMpIhh8+s36Tyf dSJ1BgJVg40nhXK2JCa/qFuBZXBP9DF4ZvbX35p7A8MPV0P7yAr35n4ue3/OXBr2sliq CUDA== X-Forwarded-Encrypted: i=1; AJvYcCV3PJwQo7tPlOEfm4KtC8MeNdVUEjtM6Z7/rZkIkzux08ZFjJ6WvjcktfXwHVthg995nrDE+Xzyluzhj4RX@lists.postgresql.org X-Gm-Message-State: AOJu0Ywt5gN02sf+P9osipYCkC2kmeGcHO80ELDaL7AZcTssHgHr8IfX L6FSY+sjx9sIoBZvbuoqUMTch0UhNIrlZ/VXZLZDWUiCwRjgnpmCvG/3KI+mcpoXjD4fhZNGJeu e89jlwtJ8LX8DUS5NMRDQVuL/Td3Viwg= X-Gm-Gg: ASbGncvAOMosrANrNmSlX5L0g4qweBDlXjFnzP1eWfIREnQ1VaoWQWV0mork9pHE4I7 CTswgY8l+8/WKoQ3c2dbVFq7lN2gQut+9eynlNzXyTEgX7dbHxcctAWhbs2iIbw7s3482Hphf2Z 1xU7AOy+ujRZIRmhNcycjRoNdDS3fnbXe078LO+P/sPsrLC3XMgzK9kojDJ2oUnHWHxecQuOYZG 1zHAF9ycdwg6tLu31ZY X-Google-Smtp-Source: AGHT+IE8KrNx3AjtcdUGFFNlyjJGwsdOEhH4rc6/orRpzelTlgPffKd3hWCLgbZ73BE6DI9l+N34XGlWQg7oNBXXpoA= X-Received: by 2002:a53:b10b:0:b0:601:3a74:c84f with SMTP id 956f58d0204a3-6102831aea3mr5873704d50.25.1757409632318; Tue, 09 Sep 2025 02:20:32 -0700 (PDT) MIME-Version: 1.0 References: <87il22cj51.fsf@163.com> In-Reply-To: From: Richard Guo Date: Tue, 9 Sep 2025 18:20:21 +0900 X-Gm-Features: Ac12FXwxwP9Ypnfsx0OZCyEY2Pa5YcA2mhILfg4GveVtT-Xog2uriRvblOz4K8E Message-ID: Subject: Re: Eager aggregation, take 3 To: Robert Haas Cc: 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 Fri, Sep 5, 2025 at 10:12=E2=80=AFPM Robert Haas = wrote: > On Wed, Aug 6, 2025 at 3:52=E2=80=AFAM Richard Guo wrote: > > What we really want to exclude are aggregate functions that can > > produce large transition values by accumulating or concatenating input > > rows. So I'm wondering if we could instead check the transfn_oid > > directly and explicitly exclude only F_ARRAY_AGG_TRANSFN and > > F_STRING_AGG_TRANSFN. We don't need to worry about json_agg, > > jsonb_agg, or xmlagg, since they don't support partial aggregation > > anyway. > This strategy seems fairly unfriendly towards out-of-core code. Can > you come up with something that allows the author of a SQL-callable > function to include or exclude the function by a choice that is under > their control, rather than hard-coding something in PostgreSQL itself? Yeah, ideally we should tell whether an aggregate's transition state may grow unbounded just by looking at system catalogs. Unfortunately, after trying for a while, it seems to me that the current catalog doesn't provide enough information. I once considered adding a flag (e.g., aggtransbounded) to catalog pg_aggregate to indicate whether the transition state size is bounded. This flag could be specified by users when creating aggregate functions, and then leveraged by features such as eager aggregation. However, adding new information to system catalogs involves a lot of discussions and changes, including updates to DDL commands, dump and restore processes, and upgrade procedures. Therefore, to keep the focus of this patch on the eager aggregation feature itself, I prefer to treat this enhancement as future work. - Richard