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 1uvzCw-004Y7g-Qb for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Sep 2025 14:20:31 +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 1uvzCv-00CSrb-Tg for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Sep 2025 14:20:30 +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 1uvzCv-00CSrS-GQ for pgsql-hackers@lists.postgresql.org; Tue, 09 Sep 2025 14:20:30 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uvzCu-001UV6-0T for pgsql-hackers@lists.postgresql.org; Tue, 09 Sep 2025 14:20:29 +0000 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-b02c719a117so1006197666b.1 for ; Tue, 09 Sep 2025 07:20:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757427627; x=1758032427; 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=UrNRuWsis33AjtbDY9AsKRYfWnX+JzjLQNGTo2hHKXI=; b=fq6qHMMqXe2Hm6sp8kw2Q2pIGuXqm3VLjxDviYWsyHnpSd1zv9T1GV0pk82TqkK6pb lHNpuf7rUu/5/zXcIrEsAmU2lTHmF90+E4z/jJ7kSdLEfjYEW5lzSuGqGYfraa2ubDOm O28WajOk+uOzIbWYVaXo+yX8u+SMFSktKhiQJoysVN/tHlVaU4D6CHw4JDNt/AuXsDbM 4Xyziyacgsyjj0sHJaJbSKwkx202F+Ji32bAYjbT5+IltbzNWeD5gY0srJU2vjR4CTC5 5eVTiS56U+j3PCBGHMdCInn6TfxNGu0gyN4xQaY3EqbZMC3CocwEtaJrvHKBzYa3geDT h1rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757427627; x=1758032427; 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=UrNRuWsis33AjtbDY9AsKRYfWnX+JzjLQNGTo2hHKXI=; b=bXva9/cU0MII03PT8wB7YsOjnfojSMO+cco/JTo+ER1mmoz3lBw9d7/0BLcJH02OHf QsZgYKZQCwzRRVUd30mFydJcU4JCGNO0aA0xZdWUc8fZE/btaIHwLRUSjTizfpTIWGF4 NIdHXJT9LLab1XuHGNhF0uKLp5TA5tbsSGnanCl4+trsP3OT7WKj0uUc+YuFG4x1UskF KevCHX2przvYoUIcUN1q8+caiXcOV0UDjT/1LUd5FhN29BWhaffX/ct/xCWjBD755TeG wUX/olI2TcOnbl28YXCCR3fY4qZaRNyAoJvjUeoahC1x7Fs3vWixFDJH5nrxOJvEYVUE WofQ== X-Forwarded-Encrypted: i=1; AJvYcCWXr+KnVfC4kUgFdZ+uKbZ2zd+kfBXdwXLCAPbYEnCdTh7M5DQFYg/gubOWTZNoYoD9IsEyUoDpa20kK7bk@lists.postgresql.org X-Gm-Message-State: AOJu0YwFqkz4qnZl/2sPCx5g/aD30LmuJTivSscGtbDoezKH8udGFbNo Ut2YWZZ4j0hgz9M94KDRPxgFL6yOFVug5eWsIyKuhPJ+Rs9iJzUNTUWdnCZi48l2+nLYGpDzTN8 mj1wWBOryqiimOV+3XkHvC3HPXIMR8Ls= X-Gm-Gg: ASbGnculSrq9Rd2LsEmi9UyhcgntfdSLDm4h7k8c12HdDUR6OtZVuo+8zN32cjT11oR LhFccFbyPQpUH/iEiRatt7jQK7GVV8mPTOXCZY3DvFcw92Y0PqbHqdP0O/EXnhzvASu7CrbL4YB ZuqS7pmFjXHwHottzRvvX07cbpLmbVN/yfHfiYw26umxfVvacLvm85ZK0x+hyvY/gatxsU8TlDk 882BwnbdtiLmCmCI+g= X-Google-Smtp-Source: AGHT+IFdDJfrlVNLPqEnsJTWqMQLjYqbRga3NFPu9A28C3QbQFrUESYkrPYlhjwWTDIR0HOLlMBu1vY+HzOinJJ0yvE= X-Received: by 2002:a17:907:6d0b:b0:b04:7107:9758 with SMTP id a640c23a62f3a-b04b16dc376mr1070647766b.43.1757427626455; Tue, 09 Sep 2025 07:20:26 -0700 (PDT) MIME-Version: 1.0 References: <87il22cj51.fsf@163.com> In-Reply-To: From: Robert Haas Date: Tue, 9 Sep 2025 10:20:14 -0400 X-Gm-Features: Ac12FXxMVZYevnDzkzyZPrmLoSsRQKOG5WErHzleRMvHzGfmDAJO5-YRNfiMFWU Message-ID: Subject: Re: Eager aggregation, take 3 To: Richard Guo 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 Tue, Sep 9, 2025 at 5:20=E2=80=AFAM Richard Guo = wrote: > 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. I don't really like that. I think there's a lot of danger of that future work never getting done, and thus leaving us stuck more-or-less permanently with a system that's not really extensible. Data type and function extensibility is one of the strongest areas of PostgreSQL, and we should try hard to avoid situations where we regress it. I'm not sure whether the aggtransbounded flag is exactly the right thing here, but I don't think adding a new catalog column is an unreasonable amount of work for a feature of this type. Having said that, I wonder whether there's some way that we could use the aggtransspace property for this. For instance, for stanullfrac, we use values >0 to mean absolute quantities and values <0 to mean proportions. The current definition of aggtranspace assigns no meaning to values <0, and the current coding seems to assume that sizes are fixed regardless of how many inputs are supplied. Maybe we could define aggtransspace<0 to mean that the number of bytes used per input value is the additive inverse of the value, or something like that. --=20 Robert Haas EDB: http://www.enterprisedb.com