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.94.2) (envelope-from ) id 1vERVr-00Bhzk-WE for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Oct 2025 12:12:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vERVq-0082v1-UF for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Oct 2025 12:12:17 +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.94.2) (envelope-from <3danissimo@gmail.com>) id 1vERVq-0082us-KN for pgsql-hackers@lists.postgresql.org; Thu, 30 Oct 2025 12:12:17 +0000 Received: from mail-yx1-xb135.google.com ([2607:f8b0:4864:20::b135]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from <3danissimo@gmail.com>) id 1vERVo-004Ynq-0A for pgsql-hackers@postgresql.org; Thu, 30 Oct 2025 12:12:16 +0000 Received: by mail-yx1-xb135.google.com with SMTP id 956f58d0204a3-63f8719aa14so548049d50.2 for ; Thu, 30 Oct 2025 05:12:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761826335; x=1762431135; 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=9ePxI3wklkuDuWElgjrjuZIYc5CdYYkyIHSTl+sWgak=; b=RaqQq2nZ0SykmUsIi38msd6e47G3Th+VtFjbYWbT+k44tZF13F7la8143SkvGGZ7Rx plcAjLxORLbthUMeBn+3+6kR1e1Gw040SBc7QtGSeKLSlVUR7JAbjvTQfzWnp5LSJ36w VGcZA4ldsMvmNAqhWTOkyS9MyPOan4FKkjr2V4HBBpImho8QUk1Lvm3AGVT/Fhn6qpO3 IKet1RuUg6ytAYehi15aPVjqm8TxdIPmYQEqMipNyoX2x+LLXMMBrQ0VLMkQSrcEri9w pB05Sd/+Wwyf/r75x4Jd6/7yfRss9qJY+LQV6Dmmwrl7Qn1DoPoRda0qSDIfiqmjV+Mp r+kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761826335; x=1762431135; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9ePxI3wklkuDuWElgjrjuZIYc5CdYYkyIHSTl+sWgak=; b=lCzDd7fPdp5XEWMWoAJOOYoJN7hxnVhoqSgIN7+5nqEmXKDRMaVls4vvUs9MpWwQcp KcsveVD8EYfnpzUiCPK+HoQjOjOhvdS2AP1TI+obCqBKieiz5hwOdF7I/rH/jZtD+zSV m6LUgnj+KqDlvIm2hKnOJU6vxjqMb4qzPesoW9mDS/juHHAQtt4J5JRWsOQtwnObNsBf Uba6ZjqMgy9SzBv/zK5nDVF4lFVFj0YxgUaGyN3Z+yfrVYIZrftPWwmac/KePMakuOzD +8Kx96PBoIe/shT3VX0LKXcOFEgR5Zcf23uL1J5Cs4KgkPEb80WQ4RBhgcRvaB8bA7Mo oTkw== X-Forwarded-Encrypted: i=1; AJvYcCXpOuS8gIcGipmsvX7JNj7TwPxb9CqCobxoichgWc8w5ccHfXcTYPhFbq1gCu3elTiNx/N6457/28X+0hg7@postgresql.org X-Gm-Message-State: AOJu0YxsLcGoS7TyHyGAf+zPvFrJ+6huEd4NowK+nT+LigPER2hQw0eV HNygZLhthk7/v1O+67sj4MF7LRC8/MMHxFn/MGzIaZiV5Tq04XqcoXmCOivRp5Hdg+B3ixyyKNl os8TqJb2pwwGtWwaAuQc7K+n7sS5KwnSeH5umn12WKg== X-Gm-Gg: ASbGncs+MkThuRNpAiJr356J9uBf+uKXyMANNPIY9Ci16zkB98zHAxTrLHRcQwlXgyJ X2ay33BfZC1Y+HbeRrcsY0RmAHpWIqd50FtcTxfgvc+udBPgFLPxHEfdfeb8Ctrtg/hXp5tqOqo AlG8atVINcmVATq3+mfTwHe1KiQE/+OQXlKpQPMT9uPhrtrtjyMjlClLEMZjqArlv5EBLxJ2C2w a8HpGv+soJIrX/sYpbFK2PChHEFn3IrLkg26rfMe6lBnHVP4iw0goezgnRJAVo= X-Google-Smtp-Source: AGHT+IEquaGPkaVlXKAytq8vUHnKox6j+vJUd0niKYWG4sI1re2IKJnuIG9zmsKRztdltLWmnYZWHV+BTY1igrM3cxc= X-Received: by 2002:a53:d00a:0:b0:63e:e5e:6b75 with SMTP id 956f58d0204a3-63f837bbe15mr1769778d50.19.1761826335301; Thu, 30 Oct 2025 05:12:15 -0700 (PDT) MIME-Version: 1.0 References: <68f3771f-91f5-4cb7-b1de-74d9abbf0b96@vondra.me> In-Reply-To: From: Daniil Davydov <3danissimo@gmail.com> Date: Thu, 30 Oct 2025 19:12:03 +0700 X-Gm-Features: AWmQ_blXUgGYV-khXifrtRVZHRzuWduetfQPCEJJzaHcVqvmom7zK2wNMc8lPog Message-ID: Subject: Re: Batching in executor To: Amit Langote 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, 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@gmail= .com> wrote: > > > > Hi, > > > > As far as I understand, this work partially overlaps with what we did i= n the > > thread [1] (in short - we introduce support for batching within the Mod= ifyTable > > 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 whethe= r pagemode is allowed at every call. If not - it just uses tuple-at-a-time mo= de. At the same time, heap_getnextbatch always expects that pagemode is enabled= . 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 comment why? 2) heapgettup_pagemode_batch : Do we really need to compute lineindex variable 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->rs_= 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) -- Best regards, Daniil Davydov