pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Denis Smirnov <darthunix@gmail.com>
To: Mats Kindahl <mats.kindahl@gmail.com>
Cc: Erik Nordström <erik@tigerdata.com>
Cc: Amit Langote <amitlangote09@gmail.com>
Cc: Antonin Houska <ah@cybertec.at>
Cc: Junwang Zhao <zhjwpku@gmail.com>
Cc: cca5507 <cca5507@qq.com>
Cc: Daniil Davydov <3danissimo@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: Tomas Vondra <tomas@vondra.me>
Subject: Re: Batching in executor
Date: Tue, 18 Aug 2026 12:47:59 +0700
Message-ID: <33B6F9A3-BCD9-407D-97B4-CD7E13B684A9@gmail.com> (raw)
In-Reply-To: <CAN305gAEbkPkKwU18BJzZp0-KrhViavMLV-_6mcBX+qkbmmyBA@mail.gmail.com>
References: <CA+HiwqFfAY_ZFqN8wcAEMw71T9hM_kA8UtyHaZZEZtuT3UyogA@mail.gmail.com>
	<68f3771f-91f5-4cb7-b1de-74d9abbf0b96@vondra.me>
	<CA+HiwqGqeS_94wxiYa8VpymiR_OtFPKDSpX+Me=MYWO45f5yig@mail.gmail.com>
	<dbce8def-e817-4e70-a9cb-e62574724d95@vondra.me>
	<CA+HiwqGM0ZTeVHicSkGnCp-2U-jvU-KBQCkPJ0N7nAj_c2LjZg@mail.gmail.com>
	<CA+HiwqHyE7-oOvtZ+OC-4N7DvKSr8Jbu75erMLQ7O4d6gfkBhg@mail.gmail.com>
	<CA+HiwqEPMwhg6pUE4XML2rG4fRqKMpeGTtMwRPGes90f9iOqtg@mail.gmail.com>
	<CA+HiwqEZja5rJ78p3FBDZNvynWsHwanxyt6h0YaK_r84NemXng@mail.gmail.com>
	<tencent_B45268659AF0400F68EC1643950ABB6A1B09@qq.com>
	<CAJDiXggP41+-HrRzT+BmtgmS8wkoZM7b4skkQA5NAe+NFEMPSQ@mail.gmail.com>
	<CA+HiwqGufj46_4kT6z5nQrCOxp3rcMDR8fn_t33n2pDKokNRQg@mail.gmail.com>
	<CA+HiwqH-2GmTKLW9kHdnqV4KdFiPfuAdVK2TgqOM2JaaeUYXnw@mail.gmail.com>
	<CAEG8a3JKNRGwBb-C_YV6Px4aFHwd_G=AsB5AbfyU4-8YZT54AQ@mail.gmail.com>
	<tencent_164C2A5EDF8189DD70287661406D688A8506@qq.com>
	<CAEG8a3K22s9LmDZa486suFu3AV=yRuTf09j+Ww+djG63y=R8hg@mail.gmail.com>
	<CA+HiwqGkway9dcpTVmRs0Q=ZsQQ8Nx0MRjy9jfDmR8QFLnd-Mg@mail.gmail.com>
	<CA+HiwqHLjBegqeUw-babABj_icAiBTq5gh48-D3BEodVZkm8Ug@mail.gmail.com>
	<CA+HiwqEnHfjCVEo9PcTCNTCQVDBSRVeu=rPLqAc1tTafu7zowg@mail.gmail.com>
	<CA+HiwqHv1CggSbpn=n+GU=Cp1AqDD25=hzx_PTYyqjMyZO2+mA@mail.gmail.com>
	<3D8D1BA5-B8A6-400A-B605-42EEE37890B4@gmail.com>
	<30925.1784290324@localhost>
	<CA+HiwqGQPDwxK7QQNUWhqhAEwaH4Z+YQhHG5jNPYHGNzDMfsXw@mail.gmail.com>
	<CACAa4VKb75kUpptWAg5r9tXmu0=bBkWyLtFLXTR2SJ_nZEcYqA@mail.gmail.com>
	<85371DE4-6957-4408-9FAA-A4871B501AB6@gmail.com>
	<CAN305gAEbkPkKwU18BJzZp0-KrhViavMLV-_6mcBX+qkbmmyBA@mail.gmail.com>

Hi Mats,

Thanks for the feedback.

First, I would like to clarify the main point. Do you mean that
filters and aggregates would run inside the scan TTS? Or would
separate plan nodes pass native batches between them?

> … requiring a conversion to PostgreSQL-native columnar format
> would cost CPU and potentially memory.

I do not propose converting a native batch after the scan. A batch
can pass between nodes that understand its batch->ops. If a parent
does not understand the format, it can materialize only the selected
rows and needed columns as Datums.

For example, ColumnarScan and a custom batch-aware Agg node could
exchange TimescaleDB batches without conversion. Both nodes would
remain visible in the plan.

> I think it would be more generic to "push down" the operations (for example,
> the filters and aggregates) into the TTS and let the TTS implementor (under
> control by the TAM implemetor) apply the operator to the batch.


I am worried that this could turn TTS into a hidden executor. If TTS
executes aggregates, it may later need to execute sorts and joins too.

I think TTS should manage the batch format, lifetime, selection,
column access, and Datum materialization. Filters, aggregates, sorts,
and joins should remain plan nodes. They may be CustomScan nodes that
understand a specific native format.

> It would be easier and less intrusive to just modify the "getsomeattr" to
> accept a Bitmapset instead of an integer.

An optional getcolumnattr looks useful. If it fills non-adjacent
columns, we need to record which columns are ready, because tts_nvalid
can only describe the first N columns.

I still think filter columns and output columns should be listed
separately. This lets the scan read output columns only for rows that
pass the filters.

> * Add a function to advance to the next row, which would then do filtering
> and aggregation internally and return the resulting "next" row. If the advance
> function returns "false", it calls ExecProcNode to get a new batch.

An advance callback also looks useful. It should only move within the
current batch. The plan node should fetch the next batch and update
executor statistics.


Best regards,
Denis Smirnov







view thread (49+ messages)  latest in thread

Message-ID: <33B6F9A3-BCD9-407D-97B4-CD7E13B684A9@gmail.com>
Permalink:  ../33B6F9A3-BCD9-407D-97B4-CD7E13B684A9@gmail.com/
Also on:    postgresql.org/message-id/33B6F9A3-BCD9-407D-97B4-CD7E13B684A9@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: darthunix@gmail.com, mats.kindahl@gmail.com, erik@tigerdata.com, amitlangote09@gmail.com, ah@cybertec.at, zhjwpku@gmail.com, cca5507@qq.com, 3danissimo@gmail.com, tomas@vondra.me
  Subject: Re: Batching in executor
  In-Reply-To: <33B6F9A3-BCD9-407D-97B4-CD7E13B684A9@gmail.com>
  References: <CA+HiwqFfAY_ZFqN8wcAEMw71T9hM_kA8UtyHaZZEZtuT3UyogA@mail.gmail.com> <CAEG8a3JKNRGwBb-C_YV6Px4aFHwd_G=AsB5AbfyU4-8YZT54AQ@mail.gmail.com> <tencent_164C2A5EDF8189DD70287661406D688A8506@qq.com> <CAEG8a3K22s9LmDZa486suFu3AV=yRuTf09j+Ww+djG63y=R8hg@mail.gmail.com> <CA+HiwqGkway9dcpTVmRs0Q=ZsQQ8Nx0MRjy9jfDmR8QFLnd-Mg@mail.gmail.com> <CA+HiwqHLjBegqeUw-babABj_icAiBTq5gh48-D3BEodVZkm8Ug@mail.gmail.com> <CA+HiwqEnHfjCVEo9PcTCNTCQVDBSRVeu=rPLqAc1tTafu7zowg@mail.gmail.com> <CA+HiwqHv1CggSbpn=n+GU=Cp1AqDD25=hzx_PTYyqjMyZO2+mA@mail.gmail.com> <3D8D1BA5-B8A6-400A-B605-42EEE37890B4@gmail.com> <30925.1784290324@localhost> <CA+HiwqGQPDwxK7QQNUWhqhAEwaH4Z+YQhHG5jNPYHGNzDMfsXw@mail.gmail.com> <CACAa4VKb75kUpptWAg5r9tXmu0=bBkWyLtFLXTR2SJ_nZEcYqA@mail.gmail.com> <85371DE4-6957-4408-9FAA-A4871B501AB6@gmail.com> <CAN305gAEbkPkKwU18BJzZp0-KrhViavMLV-_6mcBX+qkbmmyBA@mail.gmail.com> <33B6F9A3-BCD9-407D-97B4-CD7E13B684A9@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox