Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-26 Thread Melanie Plageman
On Thu, Apr 25, 2024 at 7:57 PM Tom Lane wrote: > > I wrote: > > Hmm, is that actually true? There's no more reason to think a tuple > > in a temp table is old enough to be visible to all other sessions > > than one in any other table. It could be all right if we had a > > special-case rule for

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-25 Thread Tom Lane
I wrote: > Hmm, is that actually true? There's no more reason to think a tuple > in a temp table is old enough to be visible to all other sessions > than one in any other table. It could be all right if we had a > special-case rule for setting all-visible in temp tables. Which > indeed I

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-25 Thread Tom Lane
Melanie Plageman writes: > On Wed, Apr 24, 2024 at 4:46 PM Melanie Plageman > wrote: >> After thinking about it more, I suppose we can't add a test that >> relies on the relation being all visible in the VM in a group in the >> parallel schedule. I'm not sure this edge case is important enough

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-25 Thread Melanie Plageman
On Wed, Apr 24, 2024 at 4:46 PM Melanie Plageman wrote: > > On Tue, Apr 23, 2024 at 6:43 PM Tomas Vondra > wrote: > > > > On 4/23/24 18:05, Melanie Plageman wrote: > > > One other note: there is some concurrency effect in the parallel > > > schedule group containing "join" where you won't trip

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-24 Thread Melanie Plageman
On Tue, Apr 23, 2024 at 6:43 PM Tomas Vondra wrote: > > On 4/23/24 18:05, Melanie Plageman wrote: > > The patch with a fix is attached. I put the test in > > src/test/regress/sql/join.sql. It isn't the perfect location because > > it is testing something exercisable with a join but not directly >

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-23 Thread Tomas Vondra
On 4/23/24 18:05, Melanie Plageman wrote: > On Mon, Apr 22, 2024 at 1:01 PM Melanie Plageman > wrote: >> >> On Thu, Apr 18, 2024 at 5:39 AM Tomas Vondra >> wrote: >>> >>> On 4/18/24 09:10, Michael Paquier wrote: On Sun, Apr 07, 2024 at 10:54:56AM -0400, Melanie Plageman wrote: > I've

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-23 Thread Melanie Plageman
On Mon, Apr 22, 2024 at 1:01 PM Melanie Plageman wrote: > > On Thu, Apr 18, 2024 at 5:39 AM Tomas Vondra > wrote: > > > > On 4/18/24 09:10, Michael Paquier wrote: > > > On Sun, Apr 07, 2024 at 10:54:56AM -0400, Melanie Plageman wrote: > > >> I've added an open item [1], because what's one open

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-22 Thread Melanie Plageman
On Thu, Apr 18, 2024 at 5:39 AM Tomas Vondra wrote: > > On 4/18/24 09:10, Michael Paquier wrote: > > On Sun, Apr 07, 2024 at 10:54:56AM -0400, Melanie Plageman wrote: > >> I've added an open item [1], because what's one open item when you can > >> have two? (me) > > > > And this is still an open

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-18 Thread Tomas Vondra
On 4/18/24 09:10, Michael Paquier wrote: > On Sun, Apr 07, 2024 at 10:54:56AM -0400, Melanie Plageman wrote: >> I've added an open item [1], because what's one open item when you can >> have two? (me) > > And this is still an open item as of today. What's the plan to move > forward here? AFAIK

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-18 Thread Michael Paquier
On Sun, Apr 07, 2024 at 10:54:56AM -0400, Melanie Plageman wrote: > I've added an open item [1], because what's one open item when you can > have two? (me) And this is still an open item as of today. What's the plan to move forward here? -- Michael signature.asc Description: PGP signature

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-11 Thread Richard Guo
On Sun, Apr 7, 2024 at 10:42 PM Tomas Vondra wrote: > create table t (a int, b int) with (fillfactor=10); > insert into t select mod((i/22),2), (i/22) from generate_series(0,1000) > S(i); > create index on t(a); > vacuum analyze t; > > set enable_indexonlyscan = off; > set enable_seqscan = off;

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-07 Thread Melanie Plageman
On Sun, Apr 7, 2024 at 10:42 AM Tomas Vondra wrote: > > > > On 4/7/24 16:24, Melanie Plageman wrote: > >>> Thanks! I thought about it a bit more, and I got worried about the > >>> > >>> Assert(scan->rs_empty_tuples_pending == 0); > >>> > >>> in heap_rescan() and heap_endscan(). > >>> > >>>

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-07 Thread Tomas Vondra
On 4/7/24 16:24, Melanie Plageman wrote: > On Sun, Apr 7, 2024 at 7:38 AM Tomas Vondra > wrote: >> >> >> >> On 4/7/24 06:17, Melanie Plageman wrote: >>> On Sun, Apr 07, 2024 at 02:27:43AM +0200, Tomas Vondra wrote: On 4/6/24 23:34, Melanie Plageman wrote: > ... >> >> I

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-07 Thread Melanie Plageman
On Sun, Apr 7, 2024 at 10:10 AM Tomas Vondra wrote: > > On 4/7/24 15:11, Melanie Plageman wrote: > > > Also, the iterators in the TableScanDescData might be something I > > could live with in the source code for a couple months before we make > > the rest of the changes in July+. But, adding them

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-07 Thread Melanie Plageman
On Sun, Apr 7, 2024 at 7:38 AM Tomas Vondra wrote: > > > > On 4/7/24 06:17, Melanie Plageman wrote: > > On Sun, Apr 07, 2024 at 02:27:43AM +0200, Tomas Vondra wrote: > >> On 4/6/24 23:34, Melanie Plageman wrote: > >>> ... > > I realized it makes more sense to add a FIXME (I used XXX.

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-07 Thread Tomas Vondra
On 4/7/24 15:11, Melanie Plageman wrote: > On Sun, Apr 7, 2024 at 7:38 AM Tomas Vondra > wrote: >> >> On 4/7/24 06:17, Melanie Plageman wrote: What bothers me on 0006-0008 is that the justification in the commit messages is "future commit will do something". I think it's fine to have

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-07 Thread Melanie Plageman
On Sun, Apr 7, 2024 at 7:38 AM Tomas Vondra wrote: > > On 4/7/24 06:17, Melanie Plageman wrote: > >> What bothers me on 0006-0008 is that the justification in the commit > >> messages is "future commit will do something". I think it's fine to have > >> a separate "prepareatory" patches (I really

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-07 Thread Tomas Vondra
On 4/7/24 06:17, Melanie Plageman wrote: > On Sun, Apr 07, 2024 at 02:27:43AM +0200, Tomas Vondra wrote: >> On 4/6/24 23:34, Melanie Plageman wrote: >>> ... I realized it makes more sense to add a FIXME (I used XXX. I'm not when to use what) with a link to the message where

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-06 Thread Melanie Plageman
On Sun, Apr 07, 2024 at 02:27:43AM +0200, Tomas Vondra wrote: > On 4/6/24 23:34, Melanie Plageman wrote: > > ... > >> > >> I realized it makes more sense to add a FIXME (I used XXX. I'm not when > >> to use what) with a link to the message where Andres describes why he > >> thinks it is a bug. If

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-06 Thread Tomas Vondra
On 4/6/24 23:34, Melanie Plageman wrote: > ... >> >> I realized it makes more sense to add a FIXME (I used XXX. I'm not when >> to use what) with a link to the message where Andres describes why he >> thinks it is a bug. If we plan on fixing it, it is good to have a record >> of that. And it makes

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-06 Thread Melanie Plageman
On Sat, Apr 06, 2024 at 04:57:51PM +0200, Tomas Vondra wrote: > On 4/6/24 15:40, Melanie Plageman wrote: > > On Sat, Apr 06, 2024 at 02:51:45AM +0200, Tomas Vondra wrote: > >> > >> > >> On 4/6/24 01:53, Melanie Plageman wrote: > >>> On Fri, Apr 05, 2024 at 04:06:34AM -0400, Melanie Plageman wrote:

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-06 Thread Tom Lane
Melanie Plageman writes: > On Sat, Apr 06, 2024 at 02:51:45AM +0200, Tomas Vondra wrote: >> * The one question I'm somewhat unsure about is why Tom chose to use the >> "wrong" recheck flag in the 2017 commit, when the correct recheck flag >> is readily available. Surely that had a reason, right?

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-06 Thread Tomas Vondra
On 4/6/24 15:40, Melanie Plageman wrote: > On Sat, Apr 06, 2024 at 02:51:45AM +0200, Tomas Vondra wrote: >> >> >> On 4/6/24 01:53, Melanie Plageman wrote: >>> On Fri, Apr 05, 2024 at 04:06:34AM -0400, Melanie Plageman wrote: On Thu, Apr 04, 2024 at 04:35:45PM +0200, Tomas Vondra wrote: >

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-06 Thread Tomas Vondra
On 4/6/24 02:51, Tomas Vondra wrote: > > * The one question I'm somewhat unsure about is why Tom chose to use the > "wrong" recheck flag in the 2017 commit, when the correct recheck flag > is readily available. Surely that had a reason, right? But I can't think > of one ... > I've been

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-06 Thread Melanie Plageman
On Sat, Apr 06, 2024 at 02:51:45AM +0200, Tomas Vondra wrote: > > > On 4/6/24 01:53, Melanie Plageman wrote: > > On Fri, Apr 05, 2024 at 04:06:34AM -0400, Melanie Plageman wrote: > >> On Thu, Apr 04, 2024 at 04:35:45PM +0200, Tomas Vondra wrote: > >>> On 4/4/24 00:57, Melanie Plageman wrote: >

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-04-05 Thread Tomas Vondra
On 4/6/24 01:53, Melanie Plageman wrote: > On Fri, Apr 05, 2024 at 04:06:34AM -0400, Melanie Plageman wrote: >> On Thu, Apr 04, 2024 at 04:35:45PM +0200, Tomas Vondra wrote: >>> >>> >>> On 4/4/24 00:57, Melanie Plageman wrote: On Sun, Mar 31, 2024 at 11:45:51AM -0400, Melanie Plageman

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-29 Thread Thomas Munro
On Sat, Mar 30, 2024 at 12:34 PM Tomas Vondra wrote: > Hmmm. I admit I didn't think about the "always prefetch" flag too much, > but I did imagine it'd only affect some places (e.g. BHS, but not for > sequential scans). If it could be done by lowering the combine limit, > that could work too - in

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-29 Thread Thomas Munro
On Sat, Mar 30, 2024 at 12:40 PM Tomas Vondra wrote: > Sorry, I meant the prefetch (readahead) built into ZFS. I may be wrong > but I don't think the regular RA (in linux kernel) works for ZFS, right? Right, it separate page cache ("ARC") and prefetch settings:

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-29 Thread Tomas Vondra
On 3/29/24 22:39, Thomas Munro wrote: > ... > >> I don't recall seeing a system with disabled readahead, but I'm >> sure there are cases where it may not really work - it clearly can't >> work with direct I/O, ... > > Right, for direct I/O everything is slow right now including seq scan. > We

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-29 Thread Tomas Vondra
On 3/29/24 23:03, Thomas Munro wrote: > On Sat, Mar 30, 2024 at 10:39 AM Thomas Munro wrote: >> On Sat, Mar 30, 2024 at 4:53 AM Tomas Vondra >> wrote: >>> ... Maybe there should be some flag to force >>> issuing fadvise even for sequential patterns, perhaps at the tablespace >>> level? ... >> >>

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-29 Thread Thomas Munro
On Sat, Mar 30, 2024 at 10:39 AM Thomas Munro wrote: > On Sat, Mar 30, 2024 at 4:53 AM Tomas Vondra > wrote: > > ... Maybe there should be some flag to force > > issuing fadvise even for sequential patterns, perhaps at the tablespace > > level? ... > > Yeah, I've wondered about trying harder to

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-29 Thread Thomas Munro
On Sat, Mar 30, 2024 at 4:53 AM Tomas Vondra wrote: > Two observations: > > * The combine limit seems to have negligible impact. There's no visible > difference between combine_limit=8kB and 128kB. > > * Parallel queries seem to work about the same as master (especially for > optimal cases, but

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-29 Thread Thomas Munro
On Sat, Mar 30, 2024 at 12:17 AM Thomas Munro wrote: > eic unpatched patched > 041729572 > 1 30846 10376 > 2 184355562 > 4 189803503 > 8 189802680 > 16 189763233 ... but the patched version gets down to a low number for eic=0 too if you

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-29 Thread Thomas Munro
I spent a bit of time today testing Melanie's v11, except with read_stream.c v13, on Linux, ext4, and 3000 IOPS cloud storage. I think I now know roughly what's going on. Here are some numbers, using your random table from above and a simple SELECT * FROM t WHERE a < 100 OR a = 123456. I'll

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-29 Thread Tomas Vondra
On 3/29/24 02:12, Thomas Munro wrote: > On Fri, Mar 29, 2024 at 10:43 AM Tomas Vondra > wrote: >> I think there's some sort of bug, triggering this assert in heapam >> >> Assert(BufferGetBlockNumber(hscan->rs_cbuf) == tbmres->blockno); > > Thanks for the repro. I can't seem to reproduce it

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-28 Thread Thomas Munro
On Fri, Mar 29, 2024 at 10:43 AM Tomas Vondra wrote: > I think there's some sort of bug, triggering this assert in heapam > > Assert(BufferGetBlockNumber(hscan->rs_cbuf) == tbmres->blockno); Thanks for the repro. I can't seem to reproduce it (still trying) but I assume this is with Melanie's

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-28 Thread Tomas Vondra
On 3/27/24 20:37, Melanie Plageman wrote: > On Mon, Mar 25, 2024 at 12:07:09PM -0400, Melanie Plageman wrote: >> On Sun, Mar 24, 2024 at 06:37:20PM -0400, Melanie Plageman wrote: >>> On Sun, Mar 24, 2024 at 5:59 PM Tomas Vondra >>> wrote: BTW when you say "up to 'Make

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-28 Thread Thomas Munro
On Fri, Mar 29, 2024 at 7:01 AM Tomas Vondra wrote: > On 3/28/24 06:20, Thomas Munro wrote: > > With the unexplained but apparently somewhat systematic regression > > patterns on certain tests and settings, I wonder if they might be due > > to read_stream.c trying to form larger reads, making it

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-28 Thread Tomas Vondra
On 3/28/24 06:20, Thomas Munro wrote: > With the unexplained but apparently somewhat systematic regression > patterns on certain tests and settings, I wonder if they might be due > to read_stream.c trying to form larger reads, making it a bit lazier. > It tries to see what the next block will be

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-27 Thread Thomas Munro
With the unexplained but apparently somewhat systematic regression patterns on certain tests and settings, I wonder if they might be due to read_stream.c trying to form larger reads, making it a bit lazier. It tries to see what the next block will be before issuing the fadvise. I think that means

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-24 Thread Melanie Plageman
On Sun, Mar 24, 2024 at 5:59 PM Tomas Vondra wrote: > > BTW when you say "up to 'Make table_scan_bitmap_next_block() async > friendly'" do you mean including that patch, or that this is the first > patch that is not one of the independently useful patches. I think the code is easier to

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-24 Thread Tomas Vondra
On 3/24/24 21:12, Melanie Plageman wrote: > On Sun, Mar 24, 2024 at 2:22 PM Tomas Vondra > wrote: >> >> On 3/24/24 18:38, Melanie Plageman wrote: >>> I haven't had a chance yet to reproduce the regressions you saw in the >>> streaming read user patch or to look closely at the performance results.

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-24 Thread Melanie Plageman
On Sun, Mar 24, 2024 at 2:22 PM Tomas Vondra wrote: > > On 3/24/24 18:38, Melanie Plageman wrote: > > I haven't had a chance yet to reproduce the regressions you saw in the > > streaming read user patch or to look closely at the performance results. > > So you tried to reproduce it and didn't hit

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-24 Thread Tomas Vondra
On 3/24/24 18:38, Melanie Plageman wrote: > On Sun, Mar 24, 2024 at 01:36:19PM +0100, Tomas Vondra wrote: >> >> >> On 3/23/24 01:26, Melanie Plageman wrote: >>> On Fri, Mar 22, 2024 at 08:22:11PM -0400, Melanie Plageman wrote: On Tue, Mar 19, 2024 at 02:33:35PM +0200, Heikki Linnakangas

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-24 Thread Tomas Vondra
On 3/23/24 01:26, Melanie Plageman wrote: > On Fri, Mar 22, 2024 at 08:22:11PM -0400, Melanie Plageman wrote: >> On Tue, Mar 19, 2024 at 02:33:35PM +0200, Heikki Linnakangas wrote: >>> On 18/03/2024 17:19, Melanie Plageman wrote: I've attached v7 rebased over this commit. >>> >>> If we

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-22 Thread Melanie Plageman
On Tue, Mar 19, 2024 at 02:33:35PM +0200, Heikki Linnakangas wrote: > On 18/03/2024 17:19, Melanie Plageman wrote: > > I've attached v7 rebased over this commit. > > If we delayed table_beginscan_bm() call further, after starting the TBM > iterator, we could skip it altogether when the iterator

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-20 Thread Tomas Vondra
On 3/18/24 16:19, Melanie Plageman wrote: > On Mon, Mar 18, 2024 at 02:10:28PM +0200, Heikki Linnakangas wrote: >> On 14/02/2024 21:42, Andres Freund wrote: >>> On 2024-02-13 18:11:25 -0500, Melanie Plageman wrote: patch 0004 is, I think, a bug fix. see [2]. >>> >>> I'd not quite call it a

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-19 Thread Tomas Vondra
On 3/18/24 16:55, Tomas Vondra wrote: > > ... > > OK, I've restarted the tests for only 0012 and 0014 patches, and I'll > wait for these to complete - I don't want to be looking for patterns > until we have enough data to smooth this out. > > I now have results for 1M and 10M runs on the two

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-19 Thread Heikki Linnakangas
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

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-18 Thread Tomas Vondra
On 3/18/24 15:47, Melanie Plageman wrote: > On Sun, Mar 17, 2024 at 3:21 PM Tomas Vondra > wrote: >> >> On 3/14/24 22:39, Melanie Plageman wrote: >>> On Thu, Mar 14, 2024 at 5:26 PM Tomas Vondra >>> wrote: On 3/14/24 19:16, Melanie Plageman wrote: > On Thu, Mar 14, 2024 at

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-18 Thread Melanie Plageman
On Sun, Mar 17, 2024 at 3:21 PM Tomas Vondra wrote: > > On 3/14/24 22:39, Melanie Plageman wrote: > > On Thu, Mar 14, 2024 at 5:26 PM Tomas Vondra > > wrote: > >> > >> On 3/14/24 19:16, Melanie Plageman wrote: > >>> On Thu, Mar 14, 2024 at 03:32:04PM +0200, Heikki Linnakangas wrote: > ... >

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-18 Thread Heikki Linnakangas
On 14/02/2024 21:42, Andres Freund wrote: On 2024-02-13 18:11:25 -0500, Melanie Plageman wrote: patch 0004 is, I think, a bug fix. see [2]. I'd not quite call it a bugfix, it's not like it leads to wrong behaviour. Seems more like an optimization. But whatever :) It sure looks like bug to

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-18 Thread Tomas Vondra
On 3/17/24 20:36, Tomas Vondra wrote: > > ... > >> Besides a lot of other things, I finally added debugging fprintfs printing >> the >> pid, (prefetch, read), block number. Even looking at tiny excerpts of the >> large amount of output that generates shows that two iterators were out of >>

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-17 Thread Tomas Vondra
On 3/17/24 17:38, Andres Freund wrote: > Hi, > > On 2024-03-16 21:25:18 +0100, Tomas Vondra wrote: >> On 3/16/24 20:12, Andres Freund wrote: >>> That would address some of the worst behaviour, but it doesn't really seem >>> to >>> address the underlying problem of the two iterators being

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-17 Thread Andres Freund
Hi, On 2024-03-16 21:25:18 +0100, Tomas Vondra wrote: > On 3/16/24 20:12, Andres Freund wrote: > > That would address some of the worst behaviour, but it doesn't really seem > > to > > address the underlying problem of the two iterators being modified > > independently. ISTM the proper fix would

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-16 Thread Tomas Vondra
On 3/16/24 20:12, Andres Freund wrote: > Hi, > > On 2024-03-15 18:42:29 -0400, Melanie Plageman wrote: >> On Fri, Mar 15, 2024 at 5:14 PM Andres Freund wrote: >>> On 2024-03-14 17:39:30 -0400, Melanie Plageman wrote: >>> I spent a good amount of time looking into this with Melanie. After a

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-16 Thread Andres Freund
Hi, On 2024-03-15 18:42:29 -0400, Melanie Plageman wrote: > On Fri, Mar 15, 2024 at 5:14 PM Andres Freund wrote: > > On 2024-03-14 17:39:30 -0400, Melanie Plageman wrote: > > I spent a good amount of time looking into this with Melanie. After a bunch > > of > > wrong paths I think I found the

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-15 Thread Melanie Plageman
On Fri, Mar 15, 2024 at 5:14 PM Andres Freund wrote: > > Hi, > > On 2024-03-14 17:39:30 -0400, Melanie Plageman wrote: > > I will soon send out a summary of what we investigated off-list about > > 0010 (though we didn't end up concluding anything). My "fix" (leaving > >

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-15 Thread Andres Freund
Hi, On 2024-03-14 17:39:30 -0400, Melanie Plageman wrote: > I will soon send out a summary of what we investigated off-list about > 0010 (though we didn't end up concluding anything). My "fix" (leaving > BitmapAdjustPrefetchIterator() above table_scan_bitmap_next_block()) > eliminates the

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-14 Thread Melanie Plageman
On Thu, Mar 14, 2024 at 5:26 PM Tomas Vondra wrote: > > On 3/14/24 19:16, Melanie Plageman wrote: > > On Thu, Mar 14, 2024 at 03:32:04PM +0200, Heikki Linnakangas wrote: > >> ... > >> > >> Ok, committed that for now. Thanks for looking! > > > > Attached v6 is rebased over your new commit. It also

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-14 Thread Tomas Vondra
On 3/14/24 19:16, Melanie Plageman wrote: > On Thu, Mar 14, 2024 at 03:32:04PM +0200, Heikki Linnakangas wrote: >> ... >> >> Ok, committed that for now. Thanks for looking! > > Attached v6 is rebased over your new commit. It also has the "fix" in > 0010 which moves BitmapAdjustPrefetchIterator()

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-14 Thread Thomas Munro
On Fri, Mar 15, 2024 at 3:18 AM Tomas Vondra wrote: > So, IIUC this means (1) the patched code is more aggressive wrt > prefetching (because we prefetch more data overall, because master would > prefetch N pages and patched prefetches N ranges, each of which may be > multiple pages. And (2) it's

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-14 Thread Tomas Vondra
On 3/13/24 23:38, Thomas Munro wrote: > On Sun, Mar 3, 2024 at 11:41 AM Tomas Vondra > wrote: >> On 3/2/24 23:28, Melanie Plageman wrote: >>> On Sat, Mar 2, 2024 at 10:05 AM Tomas Vondra >>> wrote: With the current "master" code, eic=1 means we'll issue a prefetch for B and then

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-14 Thread Heikki Linnakangas
On 14/03/2024 12:55, Dilip Kumar wrote: On Thu, Mar 14, 2024 at 4:07 PM Heikki Linnakangas wrote: _SPI_execute_plan() has code to deal with the possibility that the active snapshot is not set. That seems fishy; do we really support SPI without any snapshot? I'm inclined to turn that into an

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-14 Thread Robert Haas
On Thu, Mar 14, 2024 at 9:00 AM Heikki Linnakangas wrote: > The portal code is pretty explicit about it, the ExecutorRun() call in > PortalRunSelect() looks like this: > > PushActiveSnapshot(queryDesc->snapshot); > ExecutorRun(queryDesc, direction, (uint64) count, >

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-14 Thread Heikki Linnakangas
On 14/03/2024 14:34, Robert Haas wrote: On Thu, Mar 14, 2024 at 6:37 AM Heikki Linnakangas wrote: If es_snapshot was different from the active snapshot, things would get weird, even without parallel query. The scans would use es_snapshot for the visibility checks, but any functions you execute

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-14 Thread Robert Haas
On Thu, Mar 14, 2024 at 6:37 AM Heikki Linnakangas wrote: > If es_snapshot was different from the active snapshot, things would get > weird, even without parallel query. The scans would use es_snapshot for > the visibility checks, but any functions you execute in quals would use > the active

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-14 Thread Dilip Kumar
On Thu, Mar 14, 2024 at 4:07 PM Heikki Linnakangas wrote: > > > Yeah, that's a very valid point. So I think now Heikki/Melanie might > > have got an answer to their question, about the thought process behind > > serializing the snapshot for each scan node. And the same thing is > > followed for

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-14 Thread Heikki Linnakangas
On 14/03/2024 06:54, Dilip Kumar wrote: On Wed, Mar 13, 2024 at 9:25 PM Robert Haas wrote: On Wed, Mar 13, 2024 at 11:39 AM Dilip Kumar wrote: Andres already commented on the snapshot stuff on an earlier patch version, and that's much nicer with this version. However, I don't understand why

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-13 Thread Dilip Kumar
On Wed, Mar 13, 2024 at 9:25 PM Robert Haas wrote: > > On Wed, Mar 13, 2024 at 11:39 AM Dilip Kumar wrote: > > > Andres already commented on the snapshot stuff on an earlier patch > > > version, and that's much nicer with this version. However, I don't > > > understand why a parallel bitmap heap

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-13 Thread Thomas Munro
On Sun, Mar 3, 2024 at 11:41 AM Tomas Vondra wrote: > On 3/2/24 23:28, Melanie Plageman wrote: > > On Sat, Mar 2, 2024 at 10:05 AM Tomas Vondra > > wrote: > >> With the current "master" code, eic=1 means we'll issue a prefetch for B > >> and then read+process A. And then issue prefetch for C and

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-13 Thread Tomas Vondra
On 3/13/24 14:34, Heikki Linnakangas wrote: > ... > > Lots of discussion happening on the performance results but it seems > that there is no performance impact with the preliminary patches up to > v5-0013-Streaming-Read-API.patch. I'm focusing purely on those > preliminary patches now, because I

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-13 Thread Robert Haas
On Wed, Mar 13, 2024 at 11:39 AM Dilip Kumar wrote: > > Andres already commented on the snapshot stuff on an earlier patch > > version, and that's much nicer with this version. However, I don't > > understand why a parallel bitmap heap scan needs to do anything at all > > with the snapshot, even

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-13 Thread Dilip Kumar
On Wed, Mar 13, 2024 at 7:04 PM Heikki Linnakangas wrote: > > (Adding Dilip, the original author of the parallel bitmap heap scan > patch all those years ago, in case you remember anything about the > snapshot stuff below.) > > On 27/02/2024 16:22, Melanie Plageman wrote: > Andres already

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-13 Thread Heikki Linnakangas
(Adding Dilip, the original author of the parallel bitmap heap scan patch all those years ago, in case you remember anything about the snapshot stuff below.) On 27/02/2024 16:22, Melanie Plageman wrote: On Mon, Feb 26, 2024 at 08:50:28PM -0500, Melanie Plageman wrote: On Fri, Feb 16, 2024 at

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-02 Thread Melanie Plageman
On Sat, Mar 2, 2024 at 6:59 PM Tomas Vondra wrote: > > > > On 3/1/24 17:51, Melanie Plageman wrote: > > On Fri, Mar 1, 2024 at 9:05 AM Tomas Vondra > > wrote: > >> > >> On 3/1/24 02:18, Melanie Plageman wrote: > >>> On Thu, Feb 29, 2024 at 6:44 PM Tomas Vondra > >>> wrote: > > On

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-02 Thread Melanie Plageman
On Sat, Mar 2, 2024 at 5:51 PM Tomas Vondra wrote: > > On 3/2/24 23:11, Melanie Plageman wrote: > > On Fri, Mar 1, 2024 at 2:31 PM Melanie Plageman > > wrote: > >> > >> ... > >> > >> Hold the phone on this one. I realized why I moved > >> BitmapAdjustPrefetchIterator after

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-02 Thread Melanie Plageman
On Sat, Mar 2, 2024 at 5:41 PM Tomas Vondra wrote: > > > > On 3/2/24 23:28, Melanie Plageman wrote: > > On Sat, Mar 2, 2024 at 10:05 AM Tomas Vondra > > wrote: > >> > >> Here's a PDF with charts for a dataset where the row selectivity is more > >> correlated to selectivity of pages. I'm

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-02 Thread Tomas Vondra
On 3/2/24 23:11, Melanie Plageman wrote: > On Fri, Mar 1, 2024 at 2:31 PM Melanie Plageman > wrote: >> >> ... >> >> Hold the phone on this one. I realized why I moved >> BitmapAdjustPrefetchIterator after table_scan_bitmap_next_block() in >> the first place -- master calls

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-02 Thread Tomas Vondra
On 3/2/24 23:28, Melanie Plageman wrote: > On Sat, Mar 2, 2024 at 10:05 AM Tomas Vondra > wrote: >> >> Here's a PDF with charts for a dataset where the row selectivity is more >> correlated to selectivity of pages. I'm attaching the updated script, >> with the SQL generating the data set. But

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-02 Thread Melanie Plageman
On Sat, Mar 2, 2024 at 10:05 AM Tomas Vondra wrote: > > Here's a PDF with charts for a dataset where the row selectivity is more > correlated to selectivity of pages. I'm attaching the updated script, > with the SQL generating the data set. But the short story is all rows on > a single page have

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-02 Thread Melanie Plageman
On Fri, Mar 1, 2024 at 2:31 PM Melanie Plageman wrote: > > On Thu, Feb 29, 2024 at 7:29 PM Melanie Plageman > wrote: > > > > On Thu, Feb 29, 2024 at 5:44 PM Tomas Vondra > > wrote: > > > > > > > > > > > > On 2/29/24 22:19, Melanie Plageman wrote: > > > > On Thu, Feb 29, 2024 at 7:54 AM Tomas

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-01 Thread Melanie Plageman
On Thu, Feb 29, 2024 at 7:29 PM Melanie Plageman wrote: > > On Thu, Feb 29, 2024 at 5:44 PM Tomas Vondra > wrote: > > > > > > > > On 2/29/24 22:19, Melanie Plageman wrote: > > > On Thu, Feb 29, 2024 at 7:54 AM Tomas Vondra > > > wrote: > > >> > > >> > > >> > > >> On 2/29/24 00:40, Melanie

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-01 Thread Tomas Vondra
On 3/1/24 17:51, Melanie Plageman wrote: > On Fri, Mar 1, 2024 at 9:05 AM Tomas Vondra > wrote: >> >> On 3/1/24 02:18, Melanie Plageman wrote: >>> On Thu, Feb 29, 2024 at 6:44 PM Tomas Vondra >>> wrote: On 2/29/24 23:44, Tomas Vondra wrote: 1) On master there's clear difference

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-01 Thread Melanie Plageman
On Fri, Mar 1, 2024 at 9:05 AM Tomas Vondra wrote: > > On 3/1/24 02:18, Melanie Plageman wrote: > > On Thu, Feb 29, 2024 at 6:44 PM Tomas Vondra > > wrote: > >> > >> On 2/29/24 23:44, Tomas Vondra wrote: > >> 1) On master there's clear difference between eic=0 and eic=1 cases, but > >> on the

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-03-01 Thread Tomas Vondra
On 3/1/24 02:18, Melanie Plageman wrote: > On Thu, Feb 29, 2024 at 6:44 PM Tomas Vondra > wrote: >> >> On 2/29/24 23:44, Tomas Vondra wrote: >>> >>> ... >>> > > I do have some partial results, comparing the patches. I only ran one of > the more affected workloads (cyclic) on the

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-02-29 Thread Melanie Plageman
On Thu, Feb 29, 2024 at 6:44 PM Tomas Vondra wrote: > > On 2/29/24 23:44, Tomas Vondra wrote: > > > > ... > > > >>> > >>> I do have some partial results, comparing the patches. I only ran one of > >>> the more affected workloads (cyclic) on the xeon, attached is a PDF > >>> comparing master and

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-02-29 Thread Melanie Plageman
On Thu, Feb 29, 2024 at 5:44 PM Tomas Vondra wrote: > > > > On 2/29/24 22:19, Melanie Plageman wrote: > > On Thu, Feb 29, 2024 at 7:54 AM Tomas Vondra > > wrote: > >> > >> > >> > >> On 2/29/24 00:40, Melanie Plageman wrote: > >>> On Wed, Feb 28, 2024 at 6:17 PM Tomas Vondra > >>> wrote: >

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-02-29 Thread Tomas Vondra
On 2/29/24 22:19, Melanie Plageman wrote: > On Thu, Feb 29, 2024 at 7:54 AM Tomas Vondra > wrote: >> >> >> >> On 2/29/24 00:40, Melanie Plageman wrote: >>> On Wed, Feb 28, 2024 at 6:17 PM Tomas Vondra >>> wrote: On 2/28/24 21:06, Melanie Plageman wrote: > On Wed, Feb

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-02-29 Thread Melanie Plageman
On Thu, Feb 29, 2024 at 7:54 AM Tomas Vondra wrote: > > > > On 2/29/24 00:40, Melanie Plageman wrote: > > On Wed, Feb 28, 2024 at 6:17 PM Tomas Vondra > > wrote: > >> > >> > >> > >> On 2/28/24 21:06, Melanie Plageman wrote: > >>> On Wed, Feb 28, 2024 at 2:23 PM Tomas Vondra > >>> wrote: >

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-02-28 Thread Melanie Plageman
On Wed, Feb 28, 2024 at 6:17 PM Tomas Vondra wrote: > > > > On 2/28/24 21:06, Melanie Plageman wrote: > > On Wed, Feb 28, 2024 at 2:23 PM Tomas Vondra > > wrote: > >> > >> On 2/28/24 15:56, Tomas Vondra wrote: > ... > >>> > >>> Sure, I can do that. It'll take a couple hours to get the

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-02-28 Thread Tomas Vondra
On 2/28/24 21:06, Melanie Plageman wrote: > On Wed, Feb 28, 2024 at 2:23 PM Tomas Vondra > wrote: >> >> On 2/28/24 15:56, Tomas Vondra wrote: ... >>> >>> Sure, I can do that. It'll take a couple hours to get the results, I'll >>> share them when I have them. >>> >> >> Here are the results

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-02-28 Thread Melanie Plageman
On Wed, Feb 28, 2024 at 2:23 PM Tomas Vondra wrote: > > On 2/28/24 15:56, Tomas Vondra wrote: > >> ... > > > > Sure, I can do that. It'll take a couple hours to get the results, I'll > > share them when I have them. > > > > Here are the results with only patches 0001 - 0012 applied (i.e. without

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-02-28 Thread Tomas Vondra
On 2/28/24 15:38, Melanie Plageman wrote: > On Wed, Feb 28, 2024 at 8:22 AM Tomas Vondra > wrote: >> >> Hi, >> >> I haven't looked at the code very closely yet, but I decided to do some >> basic benchmarks to see if/how this refactoring affects behavior. >> >> Attached is a simple .sh script that

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-02-28 Thread Melanie Plageman
On Wed, Feb 28, 2024 at 8:22 AM Tomas Vondra wrote: > > Hi, > > I haven't looked at the code very closely yet, but I decided to do some > basic benchmarks to see if/how this refactoring affects behavior. > > Attached is a simple .sh script that > > 1) creates a table with one of a couple basic

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-02-14 Thread Andres Freund
Hi, On 2024-02-13 18:11:25 -0500, Melanie Plageman wrote: > Attached is a patch set which refactors BitmapHeapScan such that it > can use the streaming read API [1]. It also resolves the long-standing > FIXME in the BitmapHeapScan code suggesting that the skip fetch > optimization should be

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-02-14 Thread Mark Dilger
> On Feb 14, 2024, at 6:47 AM, Melanie Plageman > wrote: > > Just curious, did your table AM implement > table_scan_bitmap_next_block() and table_scan_bitmap_next_tuple(), > and, if so, did you use the TBMIterateResult? Since it is not used in > BitmapHeapNext() in my version, table AMs

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-02-14 Thread Melanie Plageman
On Tue, Feb 13, 2024 at 11:34 PM Mark Dilger wrote: > > > On Feb 13, 2024, at 3:11 PM, Melanie Plageman > > wrote: > > Thanks for the patch... > > > Attached is a patch set which refactors BitmapHeapScan such that it > > can use the streaming read API [1]. It also resolves the long-standing > >

Re: BitmapHeapScan streaming read user and prelim refactoring

2024-02-13 Thread Mark Dilger
> On Feb 13, 2024, at 3:11 PM, Melanie Plageman > wrote: Thanks for the patch... > Attached is a patch set which refactors BitmapHeapScan such that it > can use the streaming read API [1]. It also resolves the long-standing > FIXME in the BitmapHeapScan code suggesting that the skip fetch >