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 1vlOtB-00BFTA-18 for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Jan 2026 10:04:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vlOtA-007bGA-0Y for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Jan 2026 10:04:36 +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 1vlOt9-007bFb-2i for pgsql-hackers@lists.postgresql.org; Thu, 29 Jan 2026 10:04:36 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vlOt7-002teI-20 for pgsql-hackers@postgresql.org; Thu, 29 Jan 2026 10:04:35 +0000 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-34c7d0c5ddaso605634a91.0 for ; Thu, 29 Jan 2026 02:04:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769681073; cv=none; d=google.com; s=arc-20240605; b=Thsq1UNCYsEwP8tAt/cayuEF9VHwamoggGCC3LU1x2Ck2cEgPoOKiyavn6k9mVVd3o 2Z3RS9g/oEySB1KYsxjfwlSBrQNoYGE5L7DbJdCoCpOxZ0RfHJueD8uab7HzOeoLihPX Q5yXlzcO5FWoMNQTLYmYnjCrPyKBT0WiG9Dutq9rusyK/DfjXohaa8JEb/Lpn2XIC+OU j7ZQjQg1073y5Vxei/dDco+KD/MkweTzY3UFEvOrozurwk0AFE00J88SRiwqCazPoqrU P/C6wmEcy8rjHhVys4Lf8m81pNKrC/0Z6MzMp+x7UmkxTWjQPMBQKWTgoNSx1W1jTiuB g79A== 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=20KZHhWdEvt2ywsNKfNaaERnPzhbyBKwc60Z1c6ycEg=; fh=OJG5RcDuSrAlSMmrWdQntwRecgrPpzLaccwemshezIQ=; b=MSg9nKBNZ7utAeYRldzi2jY541OJuylxUCaI3UZIKw110K4qeL8OjnIVXY4Ib593GV 2oDx0Z3ErYgF2yYbme0jIMx6+RL4rllCu6M1TD3FOKQZy/HZ5O6oqKf0ndJi3Q7d7LdK Qdcm5InPUQLZC13VLHSrxxthkj+8YP6rXNkJATmcuWdzTBh5i5pohnw8rFoHGT08UJzE PlTws1CzrmUZFKX+qSHgmYncAKxI0hs4elfwCHqnHnpGIIAzKDS9oC4QyvbqD2K/i5L0 DUC4RqBImfkRZbkhJCmyi2SBbup8j1KbW821n+7KxNzCY2QFzhszqF0eH6jjenLgRY3r 8oSw==; 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=1769681073; x=1770285873; 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=20KZHhWdEvt2ywsNKfNaaERnPzhbyBKwc60Z1c6ycEg=; b=a4jzfbrLKgW59Xwc2rW46JIsz/ssFl4rMevFlRY7FtyUSQ+sSyE/MARZC39wvL1APX euOzh+rlD3bwr9uIs+qpLbSK+ZlQRM92lC8kYrbI+pMnSiZPBBXSgas62CJyMJWh9rTC +UDi80nfTIj/dxvNuuSDuvLZir5aVd0lEV/e3CuSPSl8sjByt27XNuIR9OZ52G8rJKf/ Lv6IyzFxFi17GAS7Y81WgJTGcODSSrWqOgLs/UHuBOzheG46/ZcCE+3k3iMS/Xa+NhQO Z2NP/slp0c2an7ZaHoNHjS9Hcz5U5amMQ6IvM4c9Q0dDY3VB9s+hebagYgP4e5laIGnH ztzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769681073; x=1770285873; 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=20KZHhWdEvt2ywsNKfNaaERnPzhbyBKwc60Z1c6ycEg=; b=Dp3VpyIcml1mitmdcBGxIuZQVowrlkelO4tn7GT7/3aMEegilFkVzGY4z8yyRJem8m azrUjfjFP4nSKMd8itH71lu5r+zrdVm1Ze/VZ/Ph9zH4SOtKVt+lyDprYxTN0yy3SCs4 gzboy7oTbRXzKIm1xD+NBYOdxW36mmAnarmNGGN46c3Cnk02cxm3u2dpmKm3F1aseg4+ t+VB6nJeHN1bk81HHRKQkV1spr2TWDcxwGwIpQyJ1CV7z+Xu/71n6A0HOPDk7g2bnfIV fSmz9v9oc1rl3vioGGNiP3LGPDwp+CQwSazJPPD3QyDjPJZ2jYLcu/BBy0iEL+9ozVhX Z+Ug== X-Forwarded-Encrypted: i=1; AJvYcCWLUdqjz5Yq13+bhi9wFkrG/J0oqUPkWeZlGq/tSkesQE0bIFdQZ8xt1FpQYl9FI7yv9jxGzAjNu0juSY8l@postgresql.org X-Gm-Message-State: AOJu0YwjyU678kq9PAv7WIOLAYQr2FyNxqJmZYS5wCWKPW+J5I3TmCRG udR/yHBPlE1VD+xI467t/imUli8zNeUkhAcA/kzLf8k4b+szpi7o3vFykYkDivt73GMPyQNvNai RRF1WvHGr7m4XP3mjkS7HY46xuWHSFZY= X-Gm-Gg: AZuq6aK+ZIeCGAMrPqND5u2NQalzf+ZTkU044VC+P5ZUuKtGklvB0uvjczbQ7lCj9B4 /NszTQwC6kNgKnNdF15qolDWCf4SYz49HRup0cP2ImOmBwWY7Gd2Z1WgiO63I3vyhcjD7JMYq+R EZ8ogJQBdb5sraWxeQVxyJq+I8VsTE6gDUEAGLxesFMCauMIWlNdnHimk/G7eV4Pdh5Fj81pScT ZcdXwSDyeKICLkeEq3L+tZ/q57s6YltdWY6EnV06cQWpMwmMCe8Brs0+y73UMvPxhu7Uu8= X-Received: by 2002:a17:90b:4d8c:b0:352:be45:1063 with SMTP id 98e67ed59e1d1-35429ac7eebmr2147962a91.10.1769681073415; Thu, 29 Jan 2026 02:04:33 -0800 (PST) MIME-Version: 1.0 References: <68f3771f-91f5-4cb7-b1de-74d9abbf0b96@vondra.me> In-Reply-To: From: Amit Langote Date: Thu, 29 Jan 2026 11:04:17 +0100 X-Gm-Features: AZwV_QgnJCYV76xW6DfCyZOsTZsyUvOS1RqNcWAfpO6hL9fh7VST6qLUUYLpmNU Message-ID: Subject: Re: Batching in executor To: Daniil Davydov <3danissimo@gmail.com> Cc: cca5507 <2624345507@qq.com>, 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 On Thu, Jan 29, 2026 at 8:35=E2=80=AFAM Amit Langote wrote: > > Hi, > > Here is v5 of the patch series. > > Patches 0001-0003 add the core batching infrastructure. 0001 adds the > batch table AM API with heapam implementation, 0002 wires up SeqScan > to use it (still returning one slot at a time), and 0003 adds EXPLAIN > (BATCHES). I'd love to hear people's thoughts around TupleBatch > structure added in 0002. I thought about making it a separate patch so > that 0002 will still populate the single ScanState.ss_scanTupleSlot, > but that means we'd still have to call the TAM callback to populate > the tuple in the TAM's batch struct into the slot, defeating the whole > point. With TupleBatch, you have executor_batch_rows number of slots > which are filled in one TAM callback (materialize_all) call. So I > decided to keep the TupleBatch and related things in 0002. > > For scans without quals, batching shows 20-30% improvement with no > visible regressions when batching is disabled (batch_rows=3D0): > > SELECT * FROM t LIMIT n (no qual) > > Rows Master batch=3D0 %diff batch=3D64 %diff > ------ -------- ------- ----- -------- ----- > 1M 12.42 ms 11.96 ms 3.7% 8.56 ms 31.0% > 3M 38.95 ms 38.92 ms 0.1% 28.59 ms 26.6% > 10M 153.64 ms 150.28 ms 2.2% 112.95 ms 26.5% > > (%diff: positive =3D faster than master, negative =3D slower) Oops, I meant SELECT * FROM t LIMIT 1 OFFSET n (no qual). --=20 Thanks, Amit Langote