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 1w0Rwa-001uqW-2h for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2026 22:22:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w0RwY-00CCvP-0j for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2026 22:22:18 +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 1w0RwX-00CCvH-2z for pgsql-hackers@lists.postgresql.org; Wed, 11 Mar 2026 22:22:18 +0000 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w0RwW-00000002CpB-0t0X for pgsql-hackers@postgresql.org; Wed, 11 Mar 2026 22:22:18 +0000 Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-67bb19ac35aso354445eaf.1 for ; Wed, 11 Mar 2026 15:22:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773267734; cv=none; d=google.com; s=arc-20240605; b=LbnqNUukKPYtyPORuM/TXKFPOY1E3S+F4wsJ4NpuxMT9+Myl/xNpFLl0F9s4B7mvJ7 3AVW6F37SY66Alc9i405WDfhMrKatXzSGOK1kBed6IzTGq1YRn9KCqsPksxVPw2T5ZcM U3E4LlpJBtcj0N7JduzRBMEVDrhcEZIqDfSpJge4C/OBJ2SOcYDSgHrvYgkNrtypAo80 /2odRHmU8bPZ+pWBrIyQ2D2J9efzgPKoiIfE3OFCLJ/eaI26lH+UL/eo+uEp2/l3yfW3 ID3Y9pUb+ou95SltZukBnm5Uzh73a5rg6D/ZvVZDkd3WYCJLaF1vqqLth/wZ3FSYrvzF MDhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=KfuhkXWnHbiaycjClXzAwbBqMDsKZ/bn12O95Wsa4No=; fh=Yk0J4+gUZ+zm5R86THjDeZqzCXmrD+WWhu+Jy2fflkE=; b=ZD4+jTrXMYsoNrHay4/VMQqrckD1/dhlW9bOgycF/46RpaLqN8kb2n8q51DZmsAw/w lu7Y0Zok2GiroB3g/jjaqvnXqKNxa4PpfGztBpC+JIsoOHRTyXXt2wpAizB3zOYzz11h U59Et7JLQnvSYTvocD70tUVg+RA/K1KWQcoIPaUjza6eKPGrFIUzwpBg+I1TGYBeRzfW fMNKtz8fvaipWoxRn22OvO3Kutajkgi/kVWHzZkTUx3qygHAIj8wlF3ReUAyoZL2RC9w TZJ8FUu8zdiSGxQ7PdTbqAtVufx9u91G3REZ5r15FTWAG0vQmfUmj5b6cEBMH2sAsaCO hwkw==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773267734; x=1773872534; 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=KfuhkXWnHbiaycjClXzAwbBqMDsKZ/bn12O95Wsa4No=; b=HWyle/4Nb+KJasQyKE5POrpVg0HgTMIHL8goa5JrAuGRNdLURAZidnrW+vwBxsFfhA QkXu4Duw4SnujdyX8ReyLslD/JNZSqJwviYnqPy2vlf2lwEjkeUHzVf5uBIUQupespd6 K5fx6SSUuuQyOxaYii6eMlGYnOs9ALZWW1k4rUYrTNGUVLGX+7r6P4Lr83iBFwL//Ztg oyc8WV+NV8cMVrsP8BHU4QDhYvKrSv6HTojz75yAzQozAQFho2AWXuYaN3MKgFQ70OBP ix/5a7kfMHSnAQXNhWJWzIaChefbxxWq8122l6ZGrnh8nD6N1hLV/9B3FRUbL9hWjAV3 +YfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773267734; x=1773872534; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=KfuhkXWnHbiaycjClXzAwbBqMDsKZ/bn12O95Wsa4No=; b=rh7Dlnau450sv7kF/8dMHha/vpaOLrhyVkx7jRhOeyQRCTU6DQSJdq6qN6ONN93kJJ 0Cqz8b9SMCJmrtEvH6MGh8PM67rn4qXLZT++0sg9Gb96n+Z+0DIJut8ofB+kvWqevX5H ICTwDj9i49u74yQ7/1kRwyj0fd3wyve9qriaKC5h+45Vvu/JgIWVtnE4Jke5PKdmMaMY H3Kx1ATrsb7SkWcW6YxJoTzjLNhu2R8FFslUhfnirWcEvGcUqzQqcyEuXWZp4rVxgCcl KZEmOxkzxLjslCszrSGY6TFKFlHJ3VqoRtZneeS/JSCedEfIpRa6qgWw/zBzccckSOz0 glrw== X-Forwarded-Encrypted: i=1; AJvYcCUKfTpgtBZMl24Pdfjnp5fvF3M3nmveHD3O0mLhDNlDSXGBrvjR72S7hqGwqbFTHT4ufVZygaFWxP8cA3lR@postgresql.org X-Gm-Message-State: AOJu0YzbMu2AOkI21emDmKLqifWAD/2WeN5V8Dd++c9QxsabimZSZXMd g7KDeVHavgpiKiVPDmHlKTSaN2PboqW0FDYK+XLFizwf3BUZ0b//NWYFd65Vpb7lk++yeOMbKd7 xaHUcHwvcUnY9QLL4dZRTqg1Bi47cdTE= X-Gm-Gg: ATEYQzys3NWffNlupLS8oaIMgBIm9fgwMLDfMKamUG7cuNkFysNz8QMTplJ4pF9Y0qs RYnnWtZyVswFGwLnYvpv88N8UYimHPHhJgBboO63ahswegRB60pXPjX1dh8OgfF6Z8wPHvSyRXV kIQL2i1MPpSEgvCt11yvp70ldYOAiKa92zkFBvnGRdKWibbN8sAJnUlJHJ8Xdv4GoVI1R1pA30b uOcszcmrXcTubGqUsw92NfLGYeyqzXQsk1eRorRdEPsl+aIW+RJY0b1X0pd5f0AO3w/9/aGtPJC 5VcpundABag5l5ZlpTV0JuSKBXU9nQz5MAYTWpfSsSXQuOCdPxswO5XCGUsyqlM5DCZAxCY9wuF XFjg+ERS6JkRvnDX4IjbtjsOYdKG0Ppn94ESJelaattAIXHTUtQ== X-Received: by 2002:a05:6820:4812:b0:67b:bd89:90e7 with SMTP id 006d021491bc7-67bc8a83bcbmr1944932eaf.62.1773267734195; Wed, 11 Mar 2026 15:22:14 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Alexander Korotkov Date: Thu, 12 Mar 2026 00:22:02 +0200 X-Gm-Features: AaiRm53ack9jc61Wjjp3ZEyw1yBBWKLrSs2yLKSDktmYdjIJOT9UWvRFk0Cwhbs Message-ID: Subject: Re: Odd code around ginScanToDelete To: Pavel Borisov Cc: Xuneng Zhou , Andres Freund , pgsql-hackers@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 Tue, Mar 10, 2026 at 11:29=E2=80=AFAM Pavel Borisov wrote: > Hi, Xuneng > > > > Is it worth/possible in recursive calls of ginScanToDelete() to free > > > allocated myStackItem->child after processing all children of the > > > current level, when they are not needed anymore? > > > Previously to this patch, palloc-ed "me" variable also was't freed at > > > recursion levels. > > > > Freeing/reallocating it per subtree would add churn and make the > > lifetime rules harder to reason about without meaningful memory > > savings (the number of nodes is bounded by tree depth, not number of > > pages). We currently free the chain once after ginScanToDelete() > > returns in ginVacuumPostingTree(), which matches the natural lifetime > > boundary > I proposed not freeing child when child iteration is complete. They > indeed can be reused. I proposed cleaning children when "my" iteration > is complete. At that time all the children iterations are completed > and not needed when we return level up. This is not clear for me. We need stack items to keep track of left pages until we scan the whole posting tree. After scanning the whole posting tree we can free stack items as we do now. ------ Regards, Alexander Korotkov Supabase