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 1vztOn-001PyU-1f for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Mar 2026 09:29:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vztOl-002Omc-2i for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Mar 2026 09:29:08 +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.96) (envelope-from ) id 1vztOl-002OmN-1q for pgsql-hackers@lists.postgresql.org; Tue, 10 Mar 2026 09:29:08 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vztOk-00000001QaA-1OqO for pgsql-hackers@postgresql.org; Tue, 10 Mar 2026 09:29:07 +0000 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-662b933f8d1so1645104a12.2 for ; Tue, 10 Mar 2026 02:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773134945; cv=none; d=google.com; s=arc-20240605; b=LKDUrrEGrGJo+IRRjgPeQx9yKv1T7oim+m2hNcK67difxmSsBLSDSee6cbobgNd2eB aySCQPD4WYAbFELs6qAcqwfoMjWlZPdElD4g4bH9YD+D1XcpVcYJVVjSES+NGyF3XR6o Mnkk0TmM28CST94N4x5lLkAbrny8lpwENR+92CYWfUQwOyPqvlOi2c5cZLu5RiwhUCOP 8mgWicscvKi/EQ/qLqmbfYvAeSl62rsW/jl9So/lLZk1wzksMtuIDieIsLH73RFSpfX8 NkfGqTeASk/+PQz4mxvj7EVGhWh1WH2VgsHsWjFRoCewsazilWGSEyl1FoRoqnpZrwem w3OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=Kz7iNU/DOcZF2FwhxSAXFvajmRtH7t42f3beYw/RdB8=; fh=N8eBTCGVSHZw5fDIRZAqqbi9ThyDn+eB6LmAmDyANOA=; b=gq7kWeT4No9c6inb1npikmCW00iLwjcrMD/kv1J7qgS6ugl8A80UzZ2tOyZ3Cb44F3 BtTQxVD/3wQcO6WXzl4aXjtXwnlsPBETCV4XZLtXKso1DhQtfTp3QSp3m+Mktf3twMpz tCUvndkX45yMH0VBFW3bsTkdDiWBqrqTWjR+DPNumerTYBzkZsVIOn//G1Z5IPJOXvfg 2VIpve1Ad9cA8i7/9FDdD2wtZwvtSiu4Zy9Tz6qPDzukO5k6/sKqKQCE0HTgsFbTiUlv zj4YEDzekDUw3gpFTnQioK/oZsRtR6jyhcHXy3CrrkpZXW8Ou2fhY/ZLINRKv4etqYNW SLjQ==; 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=1773134945; x=1773739745; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Kz7iNU/DOcZF2FwhxSAXFvajmRtH7t42f3beYw/RdB8=; b=jyBN7m+1UjPX+Cpu3A63OZYD7sWFI00PDBQ8Ipl/uRpTz92CI1Ci4O9BQYL0V/6QYk Y3oJUowGvaiGVVNEIyx0uteT7P6pFFCHxQHS24/vnAzvzU9sjC1ZIx6WSteShyjr42MH PMb5MHPUEwPaQ/X0CFLuaHpUO2QLNtAagR9II7n8IQIplctK102o2YXgvmcHbnlMYW/7 X0mWD/3T6YTSVtNWkRZC7i4B1kkZ9J0DqrUrUV0xkJKunROycH21cHm9BtBhQ7iidX8R DxCM4WcGw63iVq4syBLfZUr9EZfWf19182fDuFc5J9e7Gbu+jxRY7ZMZH6P+JgX8iPEH UAOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773134945; x=1773739745; h=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=Kz7iNU/DOcZF2FwhxSAXFvajmRtH7t42f3beYw/RdB8=; b=WDypRiXFjGgI1Lzin5kxGbq1+jg1CvtccrjvOvOMR/3yv8IOKwpeTmPL3Bt+UT5UfU GSInw/H4Qi4MYLV45kTn7BAdI8r/DUEFj77WHlywslxxDZY7mc08D9J8H2E3LdLaEoMk Cas6jEjgL98meG0N77OPPtuBOEkD+KgEZcqlT/+jjFMbe5X1QZ5rKaEb/9mCpTkyLFVI ZRKw0CqqalrOy106dh08xk7I+KbdgET8dMAApHqSkDvlhfw+4IkkUX3xGOy7ZuRG5owC F020NzaO8MjTDVtxv7zogJnW5C6zsEF9891WVVRr0UHJIEVw2Av565e4RVroitKX2CcG 2xfw== X-Forwarded-Encrypted: i=1; AJvYcCUZbDGbvYyo2aKJpVEA/zzCkIbyjULDFMNhNQmb1KEItQmdv4x4NpMVRu8GhNd0zRMgHWl5Cn2FJJOYwajq@postgresql.org X-Gm-Message-State: AOJu0YxGNdSQQVjkWZCPRk9YhASO3HlUtgZurb3PFJYmIIsymWJGm/Ib 4s4YdZym9ABTsbKNKeGMDW/KyAiuWpo1eiztyXPl4W7x6P1VVsjpOzMuXSP0LZVrmr42sCQwbmA +ogEGSDRJwnmuStMeFnfU+kM6BQlHu50= X-Gm-Gg: ATEYQzwnxXYeafRKRNWhWcQWg+QZZGoNXMmDcytbIeoAAoF/mc+cks7aOmlGzOsAfEz KIb4UdXYE2zwgussJDK8PYwJ/NCWNzsjF6eDgs4pvURi3vY6qXmLzay8Z+mD1+v3eXkw7K7MRWk ePtBaV6Av5e4dO8/y2jix8gp+wyUFti7yd4vAh/qZIjiXhQYE/pNzFChfAPtcSy4DGMADqCvtmC UtXYW7f42+CbskKq2berszpptG3BUXrzSKWbZVw/qc1ezbX4HT9HI/WcUaCVfaJqKAxHTD6en4G MZDW2Ql5cUUkpeCpTR3t X-Received: by 2002:a05:6402:348f:b0:662:f70f:d041 with SMTP id 4fb4d7f45d1cf-662f70fd1e5mr70407a12.6.1773134944755; Tue, 10 Mar 2026 02:29:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Pavel Borisov Date: Tue, 10 Mar 2026 13:28:53 +0400 X-Gm-Features: AaiRm50oemlqM5I4urQQv83SbPa9jRvbznHfL4G9cPfb6IHl5AHaxqo97Z6jsOo Message-ID: Subject: Re: Odd code around ginScanToDelete To: Xuneng Zhou Cc: Alexander Korotkov , Andres Freund , pgsql-hackers@postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. Regards, Pavel Borisov Supabase