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 1v48Il-0098Iz-1h for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Oct 2025 01:40:11 +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 1v48Ii-005dEm-RT for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Oct 2025 01:40:09 +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 1v48Ii-005dEc-EE for pgsql-hackers@lists.postgresql.org; Thu, 02 Oct 2025 01:40:09 +0000 Received: from mail-yw1-x1136.google.com ([2607:f8b0:4864:20::1136]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v48Ig-000xl5-07 for pgsql-hackers@postgresql.org; Thu, 02 Oct 2025 01:40:08 +0000 Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-71d5fb5e34cso6540247b3.0 for ; Wed, 01 Oct 2025 18:40:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759369206; x=1759974006; 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=+267pxZfln7iwrvTqbzr+RSmnqxuKHyUgPQN3+EX3zY=; b=BYroNVnPemw/DzIgtxcdaQhwsQUDhxfBe6CNvqYXbEbF+QeHuJW9Q6dN339OfJJknL 3UVNqSvluKQDLxazAFC6+dsO+uvKL0UN5zXvtWVtwh7ytBsYqQkRu9IqwsC5v7c5F7Iz GD+qIljjPsukXsPO8d4u0tLK85v6ZstNzwpsd7npGxiNhxmcF9zqoJqbNg6rbyvgiY2T /IKpcfd29l+kKZpN/hQHa4KhRmlw9h1k3702wUAxhYkrhmpi6FWTdrE7NlHeLFYE79qn zzlOTIUfrhvHuzAkh7/JWDT+ZVnQ1vqNlc+67ha1qM9WdyijrZ3VGQ7BXPLP0d6Xl/DB i4bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759369206; x=1759974006; 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=+267pxZfln7iwrvTqbzr+RSmnqxuKHyUgPQN3+EX3zY=; b=sbW9MPAyx2C1px7K6KTB8a9tdBoMnhGltVBk1x9QEpD+lcHLVoGran7UqxNyui8PyN n14sO/m6fn+byXI7PifovgfUgYLwQyl9kl93ifXaTlL7uq4FihmpvXgQWVw4uRE32sYh wm4Orc5/y6fn8WYDIp2j0uYLzbTYUlUEgT6FQ/zmAXVnkzKNrcLxotYsyTZAv2pRmILG IKVBQ9sWp67pK6n2wbyCFYm8J02aAeXBkENYIFUEYBCY+YHJM6aBBehFUuIswEsaU3Xl CmRKi4IRQisS5xGjEjzvIu7WR+usMj5dI+7kedt7LtgEwOzSW2IFXSe+B45SsyifuMcj YmiA== X-Forwarded-Encrypted: i=1; AJvYcCWrBvIiGBZ1X/S0zy2XiUTAGSqB7g3QMiUVZWC1p3KlJpFT+pkU5MWn0mMNfpH973dRiSCdnIaHoZ8fsStz@postgresql.org X-Gm-Message-State: AOJu0YyVwFqwXKolPGXEK4xqlra8Z/sDnCRJmeg1UicAyO6wEH2ughXP pWlhhifoD09GXj38VWSjj8vOZBFa6j3u+l2u5gHxobZFPeMQstOo2EDVWvAJ0pD4/tsyiIOgXCI ZB3xUGBaG0+1Zkf7ZRhUX6QJeDZOf3No= X-Gm-Gg: ASbGncspSkegONhSVt86jwR+xcq7JrMaXv3Co5sK1d6WrBuwzXwM2S/al+m2MHD5woA V9WOW+2RQbL/EBh9Ag3Y88rmzecVanb7eFdGm2Fjo6jDSnbZXt6Cym+X3BfKIK/0tMi32zeInLY PoRvB2wEhcR41TZPf1D/Tq1rr49Sxb2DZPU8ZTrxine488l0bE5kN2m54RtT4VTSoW8bwQrLQwV uZDYUvP9LkJ8cL2n117c0ODFurOnWf9/g== X-Google-Smtp-Source: AGHT+IGhsX4+8jaOpxEgP/2VEGrtiVrVxMP4Ov5ogCFjDNctkNBTfXUwr0pkB0vVMZOMbHp1suFCR8LvSoRJLHsw4OY= X-Received: by 2002:a53:c9c7:0:b0:632:eae9:5cd7 with SMTP id 956f58d0204a3-63b83a2c483mr1238508d50.4.1759369205989; Wed, 01 Oct 2025 18:40:05 -0700 (PDT) MIME-Version: 1.0 References: <87il22cj51.fsf@163.com> In-Reply-To: From: Richard Guo Date: Thu, 2 Oct 2025 10:39:50 +0900 X-Gm-Features: AS18NWDlCJPTo5-wT1xU-B6mdgO7nIXDRRF3fiV-WAWMiwC9csByiorhSCqEfVY Message-ID: Subject: Re: Eager aggregation, take 3 To: Matheus Alcantara Cc: Robert Haas , Tom Lane , Tender Wang , Paul George , Andy Fan , PostgreSQL-development , pgsql-hackers@lists.postgresql.org 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 Thu, Oct 2, 2025 at 10:13=E2=80=AFAM Richard Guo wrote: > On Thu, Oct 2, 2025 at 8:55=E2=80=AFAM Matheus Alcantara > wrote: > > The query 31 seems bad, I don't know if I'm doing something completely > > wrong but I've just setup a TPC-DS database and then executed the query > > on master and with the v23 patch and I got these results: > > > > Master: > > Planning Time: 3.191 ms > > Execution Time: 16950.619 ms > > > > Patch: > > Planning Time: 3.257 ms > > Execution Time: 3848355.646 ms > Thanks for reporting this. It does seem odd. I checked the TPC-DS > benchmarking on v13 and found that the execution time for query 31, > with and without eager aggregation, is as follows: > > EAGER-AGG-OFF EAGER-AGG-ON > q31 10463.536 ms 10244.175 ms > > There appears to be a regression between v13 and v23. Looking into > it... I noticed something interesting while comparing the two EXPLAIN (ANALYZE) outputs: the patched version uses parallel plans, whereas the master does not. To rule that out as a factor, I ran "SET max_parallel_workers_per_gather TO 0;" and re-ran query 31 on both master and the patched version. This time, I got a positive result. -- on master Planning Time: 5.281 ms Execution Time: 7222.665 ms -- on patched Planning Time: 4.855 ms Execution Time: 5977.287 ms It seems eager aggregation doesn't cope well with parallel plans for this query. Looking into it. - Richard