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 1x1ie5-005NaD-0J for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Sep 2026 10:56:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x1ie2-00By0u-2d for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Sep 2026 10:56:42 +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 1x1ie2-00By0U-1T for pgsql-hackers@lists.postgresql.org; Wed, 02 Sep 2026 10:56:42 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x1idz-00000002X52-3QVX for pgsql-hackers@postgresql.org; Wed, 02 Sep 2026 10:56:41 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-6a623987d32so1445128a12.1 for ; Wed, 02 Sep 2026 03:56:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=planetscale.com; s=google; t=1788346598; x=1788951398; darn=postgresql.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=dMrn0GXB6ZEXsfqkuwkMpHOI42HtbD6tPY1X238whLw=; b=FFUCUPXz2qbTWYoE1h+L1DNUQ7+eagDaSxhaVPsbePtSxWiYYkgW0+DLvtko5/aVQw gbcEyzl4jnsyurw9Jt0TVS/eI0/30AWfWqU2vH0vSGE1PMpCpth1Ytp5JcLa6icf6F3D 7AO9dJDA1vPPXFoKO1hRCaLh5PX9K6lNl3fvRaxPJ+tXxfaCu5vdO7N8UJ3nQgw6Wu5q CzQqSAbBt/7ar0O3ljkzs4tw6sr+hmOOSTU4FgZQ2SWzJKedkK4Xs4Gi8HZmoFSAShiO HZsvCDd7NnnYHsRYnrvDzasp0395gJ1FP0cHbDSaUvs5OyUA+PkvBnHOKtLar5i36Dhi dsHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788346598; x=1788951398; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=dMrn0GXB6ZEXsfqkuwkMpHOI42HtbD6tPY1X238whLw=; b=UyE2k/yAkXIFJHJvLoCJxIzBP4k4OBR59eCpWL5fS5C11g/YBmqWVn6t9Ypv24n/+3 jwx7auIsDwXgRl5fs6KO6lUxgSeqVW2PhBOMq2ILuqrETKTTbVWB8C+Qh3vaVFDqdueB AeUQPjKpVKb05UZhxSe/IKhuMMhrTXYoqKta8ZdnmaES/XbndPPSODJsRPg80CusuK/s imyIctQ/IhuSokNRyqK7v3VeHCbFEJDBCNO7vJQwQvLXe5LFc/RRBFGAieV2Q1qYF0Ro 7ldxOYhEIy5HKzvicd15VhSPc6LeMkhNEivuJDYsT96qHYhTMGabe1GxiFXy5MhsHwqC /cyw== X-Gm-Message-State: AFuF++k0ag2ckgyZkWae8ZJyEgedjq1V78wJ8LMgH3zaOekjTC6t3Hme TwDgupqor5bps0UTN0ZPan/T97F9WaKVSpcSXhW7Ru0pRr4ERRq2XRiY+ctTzZoeuEI= X-Gm-Gg: AYBFou0LpnIUf25JicBwD0Hmn2+Oqs8PuGXgHPXwe8cKXCXrjSuw5ZjEXnJXweWyVjk w1S7pNzpaMj40m4ZH7w/RYTFHq2JXe3nJEWN1mq7elUJIAB2fY4lzAh934XdyIj621hYjn3zq0M HSyTJAPdsmkEJ2T3lki/hBnZq1rwvBbhx3l2r6I5fMdXilpmhWB1ibv2f3o6fPikykwey20PsjS /CrMLHyHmkc/6RZqVAhkrJgICp+vQF4DtWBn9cCE/MK647ywq/M6N2fJ6O1Kj/wW22DcEdPOLeN h7dewtiHabzYnCNUAD9tS/E3DASrhXogRabrN/1k+cJ5DybPqpFAFuq/QkwkDzsryFGcqKKI2XV F6e9fYKBYGaNBq1J+/CvKt8Jk3Ayt+F06tXRsk5SpswghVGJoAlzP+AE6fjbvmsrX5iWLUlNmmJ ED8XDA1BlcGjfGiNrpKyodIZVxwrPNDddQ89eaPFQXFuRYhUMHZEh4oYvBqEbVHO+naWiRqRE5Z a93Cf1K4FEoPV4vxaMtPReYmmf5MD13VLATj/bVIdEu1AXAhcR9r23OhjW4 X-Received: by 2002:a17:907:6d11:b0:c25:8fdf:5d with SMTP id a640c23a62f3a-c25d5476409mr177623766b.13.1788346598441; Wed, 02 Sep 2026 03:56:38 -0700 (PDT) Received: from ?IPV6:2a04:4540:6524:1900:a184:ca28:6eaa:dcb6? ([2a04:4540:6524:1900:a184:ca28:6eaa:dcb6]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c25d039d4f7sm109103066b.29.2026.09.02.03.56.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Sep 2026 03:56:38 -0700 (PDT) Message-ID: <4e8af360-9c74-477a-806d-8b433a37bfb6@planetscale.com> Date: Wed, 2 Sep 2026 12:56:37 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Many of psql's describe functions bloat cache / waste mem To: xliu19163@gmail.com, Andres Freund Cc: pgsql-hackers@postgresql.org References: <7u2wehplakrobc5rvuomgurjqc3osns2n6fdxsajvhpqbzarmi@4kknsc6ymuja> <19204305-0261-4b63-81fd-85da5be78adc@planetscale.com> Content-Language: en-GB From: Jan Nidzwetzki In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Xiaoyu, On 01.09.26 05:00, xliu19163@gmail.com wrote: > Hi Jan, > > Thanks for the detailed review and for confirming the memory reduction. > > Attached is v2. I followed your suggestions: Thanks for v2 of the patch. It applied cleanly to the current master branch and check-world passes. Testing ======= I ran a few tests locally, and it decreases memory usage for several commands. I used the following script for verification: sql="FROM pg_backend_memory_contexts WHERE path @> (SELECT path FROM pg_backend_memory_contexts WHERE name = 'CacheMemoryContext')" for c in '\d' '\da' '\dc' '\dd' '\dD' '\df' '\di' '\dm' '\do' \ '\dO' '\dp' '\dP' '\ds' '\dt' '\dT' '\dv' '\z'; do printf '%-5s ' "$c" psql -X -qtA <