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 1vkIzs-00DOvU-0w for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Jan 2026 09:35:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vkIzr-00782D-1F for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Jan 2026 09:34:59 +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 <3danissimo@gmail.com>) id 1vkIzr-00781l-0L for pgsql-hackers@lists.postgresql.org; Mon, 26 Jan 2026 09:34:59 +0000 Received: from mail-yx1-xb131.google.com ([2607:f8b0:4864:20::b131]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from <3danissimo@gmail.com>) id 1vkIzp-00000000WDA-10Bm for pgsql-hackers@postgresql.org; Mon, 26 Jan 2026 09:34:59 +0000 Received: by mail-yx1-xb131.google.com with SMTP id 956f58d0204a3-6446c1a7a1cso3387371d50.3 for ; Mon, 26 Jan 2026 01:34:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769420095; cv=none; d=google.com; s=arc-20240605; b=fiJo0xzAGRpnTiCQWtGd12ix/SHwNbK+S6qnJFWttgvgwl4LGXHByBVZzhRg5Rmyvb diWenT57tbNy1MB3qBiokp24ulaT9X8z8qV9s8+X9zujSmdQ1sBhWCbAC5DKnrVE8/Ul av5HfJd3OsLi1K/MFtr3Rg039w96KLw7FRO2ZDjshq60m/P0jC5WwUg4L6fpceHSGAaW o+VldbeLC3r2YP/7jw8kYa7RoAFvsaq0HuuiDS7hn8m9HRI9Hnr6V4vMlKVdHT7ubsvY x+VR+MBMIEcsdDHiBM2y+h4EsMz3N+9B6iVvEC2QAcrTIJTYvrqlg37+bQ7C5c9FKzyC OK9Q== 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=HQrg9BBiIIEGYGAoA7ULcLf/9tCi8JHYnqvRf6adx9g=; fh=Te6tzYtyFgtT/T/JrrfQ0QqQB8EjpqKwpcKhQKEpFV0=; b=DkQQ5s8RVY0pHjXRDVfp2H5CEtmgMQ096yKy3R6ZDhJ+/vbwV86OCEEVI5+NE8xrlS hv8ro9DRre9itXwX6WAxTHBws96o/qn9VPnfJout1gXbPkoDy6KEZbCUNuo7h/MKkbRS tlJn2CR+EoxZ5tPDfjZd7kWYXs6FpQdj3ZGXnVbzyypl4B3aXxWfe12/9rxY/qFg+udH yqxbAVBxfCQXGaQ48d1szVwilDdzwfNIOHrEVC6h+EGRu+LKxxm78qn7bEu4Vhg8BzS3 LUILw7vdupS+ptWEOtKwLsdzUrUcN6zCHuwDzrL8AqzS0FNU5sodsDz1x/X7YjVbv8lz tn7g==; 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=1769420095; x=1770024895; 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=HQrg9BBiIIEGYGAoA7ULcLf/9tCi8JHYnqvRf6adx9g=; b=iWjFYFcO5+uAwCkmYlPL+i5hJBJqAvpWocKKySp/IE9JVB5r102241cL6A20tv2QS6 E1P7gwss0csg0gXsygv4AvefgHWaIYEH2tJVlbEZiONltwjPuW58ea14yCQkm4oRg8xE wI8i5oO2mp6+I+MmNtAx5mlmKtuOVy1PA/4QfKEF4DT2DyfeG1FGLoRvR8srqGs++3y4 46D+mnQeEjaeO2x0z38DGu/O0iHHnkQeN8haD59OQV9DHLtw97wUl9rpC0NK0Np9KOBU MsWcyA0/krGCCRxdoL3Q/U1DCNPjOxtuEOt3ksGSpxFZ1Cfive3rHgwZ5m88FgLj9Cy1 Q+OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769420095; x=1770024895; 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=HQrg9BBiIIEGYGAoA7ULcLf/9tCi8JHYnqvRf6adx9g=; b=GZlmmt7g6rXkvDtF9vmzDx0NyGf7TYfc2TEFmu6oofXqqKBYuqooaT6Tj1xmInExbO GhVICo2gVae6XPZ55mYU65QCXtBQmF8y3CZIDXQZOIF5we7fDS9KUs2i74QNPzgGE2ie lNiwjNMxElrc+KBRGmtOaY4PpZZ9nFtm3F6vkUMMD/fxxVdkm1aL3u7zGVM+zq9oeKvL zKH7pIx0vfjYMNg4HTmKue9+xkP3WL5WjqhxHWr7H602ukLJhL3+TDed316hT4Hr+ScC k8MYfqep//xYtuve6fju2F/KiKr5Vm1qOydKq2pAa7QQls8jZp8OsFqM1IWwZ/FqbWL6 DzBw== X-Forwarded-Encrypted: i=1; AJvYcCXvknw5bZ52COuqHcmRrbQWC+1OmRvVh7oTuowp84cx/sQ52G2GhIm3AaADS48ewSsKZU/ijP3r57bEgJdM@postgresql.org X-Gm-Message-State: AOJu0YzJRPKc1lH2iFB7IZV28vXNCZ+ZqFpXLIrtt99tMncZf/G5XHil 5yEqMzfvnUEtbnJIGfT503LBevKeR/5DPSKm80YfD/b5g3HifPKdNN0Z6vg1/kj526wcD5nFmbh LZbnI0INViGpYj6FiTCSLp77U2ZqJkOo= X-Gm-Gg: AZuq6aJkJPaMzn7/2+j3W50eGt8zh8s8ue4J5C8xqGsqV6tFvsf+HH86J9yTqFi3+NP MmBQG5JJyEFkfkXuO+17CEbKDIsTtGTRTWVbicfJ0MPDzNBSqE0DDrzn3oxI5e8KRsNN/uobxn9 ynAex61ebes54hwGLnDnrhu+3nGvuq1ms7PLIpaxio5oi7TB69yeDcOhSIbyPd531tzni52yhty oBsnWiXGB5d15vAMiPjsOMgVv3HzcbQ5EKQ7QmDYuKXC/91mTLoHckBU0cfCKhFs45xoOw= X-Received: by 2002:a05:690e:14cd:b0:649:4643:a8d8 with SMTP id 956f58d0204a3-64970c8e143mr2790173d50.54.1769420095362; Mon, 26 Jan 2026 01:34:55 -0800 (PST) MIME-Version: 1.0 References: <68f3771f-91f5-4cb7-b1de-74d9abbf0b96@vondra.me> In-Reply-To: From: Daniil Davydov <3danissimo@gmail.com> Date: Mon, 26 Jan 2026 16:34:44 +0700 X-Gm-Features: AZwV_QjndP5IwsDV4VSLjvqQR0arkwI6gSdGKajLobiUyMj0CasNzoTs88a30ws Message-ID: Subject: Re: Batching in executor To: cca5507 <2624345507@qq.com> Cc: Amit Langote , PostgreSQL-development , Tomas Vondra 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 Mon, Dec 22, 2025 at 6:46=E2=80=AFPM cca5507 <2624345507@qq.com> wrote: > > Some comments for v4: > Agree with your (1)-(4) comments. > 5) heapgettup_pagemode_batch() > If the scan key filters out all tuples on a page, we may return 0 before = reaching the end of scan, right? > Yes. I think that we should advance to the next page if "nout =3D=3D 0" at the end of walking through the rs_vistuples. > 6) heap_begin_batch() > ``` > hb =3D palloc(sizeof(HeapBatch)); > hb->tupdata =3D palloc(sizeof(HeapTupleData) * maxitems); > ``` > Can we just use one palloc() for cache-friendly? > Actually, we are using memory context when calling the palloc function. I.e. in the general case it will not cause memory allocation. But of course there is no guarantee for it. I saw a lot of places in the code where we are calling the palloc function several times in a row, so I guess that this is OK. If you will decide to leave these palloc calls, I suggest using the palloc_object/palloc_array functions. A few other comments on 0001 patch: 1) + void *(*scan_begin_batch)(TableScanDesc sscan, int maxitems); Is it syntactically correct? 2) /* Initialize static fields of HeapTupleData. Row bodies remain on page= . */ relid =3D RelationGetRelid(sscan->rs_rd); for (int i =3D 0; i < maxitems; i++) hb->tupdata[i].t_tableOid =3D relid; Is it really necessary? I see that we are setting this field inside the heapgettup_pagemode_batch function. A few comment on 0002 patch: 1) I guess that you should rebase your patches on the current master, because the second patch doesn't apply. 2) Maybe we can use tuplestore for tuples stored in TupleBatch? It is just a proposal - I didn't check this idea carefully. -- Best regards, Daniil Davydov