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.96) (envelope-from ) id 1w8k8X-000pnt-1L for pgsql-performance@arkaria.postgresql.org; Fri, 03 Apr 2026 19:24:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w8k8W-00DYTo-0Q for pgsql-performance@arkaria.postgresql.org; Fri, 03 Apr 2026 19:24: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.96) (envelope-from ) id 1w8k8V-00DYTg-26 for pgsql-performance@lists.postgresql.org; Fri, 03 Apr 2026 19:24:56 +0000 Received: from mail-dl1-x1233.google.com ([2607:f8b0:4864:20::1233]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w8k8T-00000000QMU-1kDn for pgsql-performance@lists.postgresql.org; Fri, 03 Apr 2026 19:24:55 +0000 Received: by mail-dl1-x1233.google.com with SMTP id a92af1059eb24-12a693cdf29so2968497c88.0 for ; Fri, 03 Apr 2026 12:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20251104.gappssmtp.com; s=20251104; t=1775244292; x=1775849092; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=vW0sGeFT48Cm7Gnd45C5Z2pnN6JChuzoJsdIiYvizs8=; b=dud2odMwgidmeo8MXNMT1Conaw1sw/7UYVSHrT0wJh3VoBQQepKAbNwKKMGucl7igV Em/9Zo4rWu+cr/ffJia4tTwrdj0ZGuXs6GfMdXzWxZBw0MUaeUN02XkflWyGD0MzfFr9 ozCOZYgBMfIV+cinVqhBW/gXtgvWCTs5y+BjUPZAkYJENv4aWc6JzEVojzpQMzjifcuz r3+f5HVMdmwHCloxjsAchRadPCGbm2QqDjA156XiUFksat9ceYS8DYy7Q2ml1LStUkHh 5fKtlZFxDJ8lgcGjMKoIEL+d+Efs30a47wRPTOj4mHpjmezy3SK6q6xbmWnhEqqPkps0 16Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775244292; x=1775849092; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vW0sGeFT48Cm7Gnd45C5Z2pnN6JChuzoJsdIiYvizs8=; b=aPJsGhzFyCHh49oaQDwPRcR/aDfrjBFT/4bquLnD3Ybhzb7DgaaGp6mf2hS0S9nfco iNTEGGzsLPzITcIq0xUWyNjYbOuuwmh823JFj+Zqfu7K0l6S51YHKyRpHPDkYNbKl3e7 +XKp7oWyVcsnWTnv9a+M1QuyhF7KQtlBdu67CdFtcNu9SSpDY3Fq/E8lIz0Pu8jNndGL sO5SIuXIi077x4b8HsIiMDievDZcxuvq3szXTDubmucwkLgej4XCGc/TB7+N118GDcsy sCbUjp3vteiP5yGxURscOMLJOmsJYFr0gFzaQF+dd02wATejJAWaBQ/Rf7A2nNTWX6Wo NBUA== X-Forwarded-Encrypted: i=1; AJvYcCVzj1LvXzy2e4v7vPzw2TFGNxrIKoIa1fyWFVwLG1K1XkKEojojl2+LzcR40WGDkCCG9L74f3vmKaS5AS/190JtGA==@lists.postgresql.org X-Gm-Message-State: AOJu0YwBspSKmRdt0Ac+2ayk+pxxIewdEjOvA3/BqTXsro2qe30E/A66 TDkRSAOwsM1dfSRofuHSTpZwLs5/8Y0v8EXH2M7wO6J5X9TI/mcX/OD17AEMvVFZnA== X-Gm-Gg: ATEYQzx8V8sneByfz1bA+0dHlCE2XO0Vdz+fe1eE/ExcP9GHaqyebc2AKg4APPDCTVg NU/3xipe2kM7r/kP6Ac6iWs4h3nAzcOXaD9G2Rzo22XrYQ7REbUnAg0HfX7JlPRQk+pqb1FeF+d YD8bvwjfGiyiUCg8G3gASnwu9VZTgcMzZecEod+tlqBkL/vkdLaMGSIUprLsliagHZ0L2JbOKHY gfPztszA6iWyZTUrzNQhYeNiaNHcJ8xKWNW/GOEqjnEkbfgmm+d9fzD/qDaoCmbE9Np9cOnRhvi fGnatkTUAhknOZxki6+vL7utHav7uOOHGRYDSgClPDvW6XEcvk0Azxw1y7g7GYVWEM8q1IQFdem cIxHe2zM5PGgrsjIwYY+m+QPZWVgEJLDOGaJNmCzmIrw0UozSPjDnc005wHQTB5cSZQsL/rgYY7 xj12Yl5uSqm4hjClGL9DYu4I22CfGeE/4z0qApAJ2n4Feb95/QvJc= X-Received: by 2002:a05:7022:220b:b0:11e:3e9:3e92 with SMTP id a92af1059eb24-12bf08ba9f5mr3035400c88.23.1775244291471; Fri, 03 Apr 2026 12:24:51 -0700 (PDT) Received: from jeff-laptop.lan (c-24-7-19-3.hsd1.ca.comcast.net. [24.7.19.3]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2ca78df5ec7sm5760926eec.3.2026.04.03.12.24.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2026 12:24:50 -0700 (PDT) Message-ID: Subject: Re: Significant performance issues with array_agg() + HashAggregate plans on Postgres 17 From: Jeff Davis To: Tom Lane , Scott Carey Cc: David Rowley , pgsql-performance@lists.postgresql.org Date: Fri, 03 Apr 2026 12:24:49 -0700 In-Reply-To: <3671092.1775167393@sss.pgh.pa.us> References: <2764544.1774985169@sss.pgh.pa.us> <2897039.1775051081@sss.pgh.pa.us> <3579239.1775151498@sss.pgh.pa.us> <3671092.1775167393@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.3-0ubuntu1.1 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 2026-04-02 at 18:03 -0400, Tom Lane wrote: > and a secondary problem is that that drives the > cost of hash_agg_check_limits to an unacceptable level. I recall some discussion about whether the memory accounting would recurse to child contexts at the time MemoryContextGetMemAllocated() is called, or whether it would update the parent contexts at the time a new block is allocated in a subcontext. Using the latter strategy would solve the high cost when there are many subcontexts. Regards, Jeff Davis