public inbox for [email protected]  
help / color / mirror / Atom feed
From: Heikki Linnakangas <[email protected]>
To: Melanie Plageman <[email protected]>
Cc: Andres Freund <[email protected]>
Cc: Pg Hackers <[email protected]>
Cc: Thomas Munro <[email protected]>
Cc: Nazir Bilal Yavuz <[email protected]>
Subject: Re: BitmapHeapScan streaming read user and prelim refactoring
Date: Tue, 19 Mar 2024 14:33:35 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <20240318151947.uu2il7iegi2gkmol@liskov>
References: <CAAKRu_ZwCwWFeL_H3ia26bP2e7HiKLWt0ZmGXPVwPO6uXq0vaA@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<20240318151947.uu2il7iegi2gkmol@liskov>

On 18/03/2024 17:19, Melanie Plageman wrote:
> I've attached v7 rebased over this commit.

Thanks!

> v7-0001-BitmapHeapScan-begin-scan-after-bitmap-creation.patch

If we delayed table_beginscan_bm() call further, after starting the TBM 
iterator, we could skip it altogether when the iterator is empty.

That's a further improvement, doesn't need to be part of this patch set. 
Just caught my eye while reading this.

> v7-0003-Push-BitmapHeapScan-skip-fetch-optimization-into-.patch

I suggest to avoid the double negative with SO_CAN_SKIP_FETCH, and call 
the flag e.g. SO_NEED_TUPLE.


As yet another preliminary patch before the streaming read API, it would 
be nice to move the prefetching code to heapam.c too.

What's the point of having separate table_scan_bitmap_next_block() and 
table_scan_bitmap_next_tuple() functions anymore? The AM owns the TBM 
iterator now. The executor node updates the lossy/exact page counts, but 
that's the only per-page thing it does now.

> 		/*
> 		 * If this is the first scan of the underlying table, create the table
> 		 * scan descriptor and begin the scan.
> 		 */
> 		if (!scan)
> 		{
> 			uint32		extra_flags = 0;
> 
> 			/*
> 			 * We can potentially skip fetching heap pages if we do not need
> 			 * any columns of the table, either for checking non-indexable
> 			 * quals or for returning data.  This test is a bit simplistic, as
> 			 * it checks the stronger condition that there's no qual or return
> 			 * tlist at all. But in most cases it's probably not worth working
> 			 * harder than that.
> 			 */
> 			if (node->ss.ps.plan->qual == NIL && node->ss.ps.plan->targetlist == NIL)
> 				extra_flags |= SO_CAN_SKIP_FETCH;
> 
> 			scan = node->ss.ss_currentScanDesc = table_beginscan_bm(
> 																	node->ss.ss_currentRelation,
> 																	node->ss.ps.state->es_snapshot,
> 																	0,
> 																	NULL,
> 																	extra_flags);
> 		}
> 
> 		scan->tbmiterator = tbmiterator;
> 		scan->shared_tbmiterator = shared_tbmiterator;

How about passing the iterator as an argument to table_beginscan_bm()? 
You'd then need some other function to change the iterator on rescan, 
though. Not sure what exactly to do here, but feels that this part of 
the API is not fully thought-out. Needs comments at least, to explain 
who sets tbmiterator / shared_tbmiterator and when. For comparison, for 
a TID scan there's a separate scan_set_tidrange() table AM function. 
Maybe follow that example and introduce scan_set_tbm_iterator().

It's bit awkward to have separate tbmiterator and shared_tbmiterator 
fields. Could regular and shared iterators be merged, or wrapped under a 
common interface?

-- 
Heikki Linnakangas
Neon (https://neon.tech)






view thread (2+ messages)

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: BitmapHeapScan streaming read user and prelim refactoring
  In-Reply-To: <[email protected]>

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

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