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 1vWy4S-00ESlM-0P for pgsql-hackers@arkaria.postgresql.org; Sat, 20 Dec 2025 14:36:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vWy4Q-00AYxm-04 for pgsql-hackers@arkaria.postgresql.org; Sat, 20 Dec 2025 14:36:34 +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 1vWy4P-00AYxe-1n for pgsql-hackers@lists.postgresql.org; Sat, 20 Dec 2025 14:36:34 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vWy4O-001g4j-1l for pgsql-hackers@postgresql.org; Sat, 20 Dec 2025 14:36:33 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-29f102b013fso33809775ad.2 for ; Sat, 20 Dec 2025 06:36:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766241390; x=1766846190; 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=bHgAKvsl92iP7Jazzejvge5mFfKgmbDDEcQv+ZW/tFo=; b=TbuYpPuQp0McPGsDFavPZUPdLRsqiMYg9l7EhdCku5nqkoBw8vQDvmds48JtJXqF81 gy3hdNJdW4ZVyrDyS0cdi2zhhbQdpuABP+IKLKl1YLptLsLqAYR8LoSjajlP2hhOl/kR IUsgksQ/ONy3hQ2llpplNuocCrgf5NEvYFdl2+YtAdlc3jK0W6aFs2gxllNlfq1VujXL guM8EtC0tJY5pGcOUgGSwgKL0ptFjCN9/TjLi9ShgapxIM5n3o7M6AMNLn6DnbKHOika kzVuEfOk9YZfSHw+HkN9aESw8Pz+qhgHEqYWDoTEvQWSqlcB3TNQut6SLn5YdDnls298 UcSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766241390; x=1766846190; 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=bHgAKvsl92iP7Jazzejvge5mFfKgmbDDEcQv+ZW/tFo=; b=MXbETGKnGMv9/ELygPiLq8a0FDyPKecIDYmPeC0C96GpZLdQsn0WfcjXnJGeMXlPBw BrYKojJbYwjKQDUKq6CNWvTz+PFvGsm5DWmaXGioFOMNw6e0+EvXJrOPSZMw6NYhdbr3 TzkS4NLsC8S+4dK6/g7Np8lBDIzrw5Nz9cpGO3HgwxGJTSfVxB3w5cjlGu/GKYnxFOF9 8LC1OAKT0+A60PGges5ZEyAD1RSyiqCo5OQiJNjGvOLjqnQsLtmYAgaRS41SGJSnU6pU owF30TLBrozB6CjKdcHB5/WWahT4Ka1fHj7Ae7xphCctcyhG0V+nweaYTQIz/Ol9qTRL yQ8A== X-Forwarded-Encrypted: i=1; AJvYcCV5SqxOi7unSnCyP1hCQaVX+jWxdWMHkC+Klh/3PZ7McdJFbHA7NECLwBfRrN4837XmrbfDT2Cw3ionSN+f@postgresql.org X-Gm-Message-State: AOJu0Yy7pFB1vjkm89pe1YSBLM27HDAPyojTwi1yr+BnReUz6KQw+gBW kTAaajALibBL72w6krIz7H6kwg+Yc4fjCG2vsl0XLfSIzvGNr9kM4Wygg0nDqtfOFUqT9qfvYx4 mtTLTl442ym9xAXeEUtPrJxP4Kw1VTbk= X-Gm-Gg: AY/fxX4v1+K/AIXgZBh4fKqRAJln8xAsvtU6dgbrz6ltszqSJthWFblNpKlCfQBchSh Of/APUfaBVUaG6wtI0yABXtoPDy9K2FAmylSymGh8f/gsnn4aXR54TC0BXJDT0dPee0JdOitEv5 DCy7ve786dFs3Uh+Yoz4WuBmc9feHZuua4CJKDmkxU/g/h90zIbVwiKjmEnsOek24GTtFF6hUXj QAEniRmqm2D2TmlPJFZ1mDQibT1S9gDasI5ry6uK9j6v7dmnD+m9AdvP6YoEJUTOYNcluP2 X-Google-Smtp-Source: AGHT+IESbHxmUatzlnxvstovgy8ABqJDq49y/CQKw5E8M2aj+QbsTkYFpF15/YiOox7NRKccJ6bRnw2J8+pV6ZMmSVQ= X-Received: by 2002:a17:902:e552:b0:2a1:3ee3:d00b with SMTP id d9443c01a7336-2a2f2229d1bmr65177715ad.13.1766241390135; Sat, 20 Dec 2025 06:36:30 -0800 (PST) MIME-Version: 1.0 References: <68f3771f-91f5-4cb7-b1de-74d9abbf0b96@vondra.me> In-Reply-To: From: Amit Langote Date: Sat, 20 Dec 2025 23:36:13 +0900 X-Gm-Features: AQt7F2rlRhHIR7-lp2avTorOyASbhsTVnB2vZOvJsOQ0OIYsyt5p3BnG3J3g1Zk Message-ID: Subject: Re: Batching in executor To: Daniil Davydov <3danissimo@gmail.com> Cc: Tomas Vondra , PostgreSQL-development 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 Hi Daniil, On Thu, Oct 30, 2025 at 9:12=E2=80=AFPM Daniil Davydov <3danissimo@gmail.co= m> wrote: > On Wed, Oct 29, 2025 at 9:23=E2=80=AFAM Amit Langote wrote: > > > > Hi Daniil, > > > > On Tue, Oct 28, 2025 at 11:32=E2=80=AFPM Daniil Davydov <3danissimo@gma= il.com> wrote: > > > > > > Hi, > > > > > > As far as I understand, this work partially overlaps with what we did= in the > > > thread [1] (in short - we introduce support for batching within the M= odifyTable > > > node). Am I correct? > > > > There might be some relation, but not much overlap. The thread you > > mention seems to focus on batching in the write path (for INSERT, > > etc.), while this work targets batching in the read path via Table AM > > scan callbacks. I think they can be developed independently, though > > I'm happy to take a look. > > Oh, I got it. Thanks! > > I looked at 0001-0003 patches and got some comments : > 1) > I noticed that some Nodes may set SO_ALLOW_PAGEMODE flag to 'false' > during ExecReScan. heap_getnextslot works carefully with it - checks whet= her > pagemode is allowed at every call. If not - it just uses tuple-at-a-time = mode. > At the same time, heap_getnextbatch always expects that pagemode is enabl= ed. > I didn't find any code paths which can lead to an assertion [1] fail. > If such a code > path is unreachable under any circumstances, maybe we should add a commen= t > why? > > 2) > heapgettup_pagemode_batch : Do we really need to compute lineindex variab= le > in this way? : > *** > lineindex =3D scan->rs_cindex + dir; > if (ScanDirectionIsForward(dir)) > linesleft =3D (lineindex <=3D (uint32) scan->rs_ntuples) = ? > (scan->rs_ntuples - lineindex) : 0; > *** > > As far as I understand, this is enough : > *** > lineindex =3D scan->rs_cindex + dir; > if (ScanDirectionIsForward(dir)) > linesleft =3D scan->rs_ntuples - lineindex; > *** > > 3) > Is this code inside heapgettup_pagemode_batch necessary? : > *** > ScanDirectionIsForward(dir) ? 0 : 0 > *** > > 4) > heapgettup_pagemode has this change : > HeapTuple tuple =3D &(scan->rs_ctup) ---> HeapTuple tuple =3D &scan->r= s_ctup > I guess it was changed accidentally. > > 5) > I apologize for the tediousness, but these braces are not in the > postgres style : > *** > static const TupleBatchOps TupleBatchHeapOps =3D { > .materialize_all =3D heap_materialize_batch_all > }; > *** > > [1] heap_getnextbatch : Assert(sscan->rs_flags & SO_ALLOW_PAGEMODE) Thanks for the review and apologies for getting to them so late. I think I've addressed your comments in v4 that I just posted. --=20 Thanks, Amit Langote