Re: Bitmap reuse

2021-07-21 Thread David Rowley
On Thu, 22 Jul 2021 at 01:54, David Rowley wrote: > Maybe the planner would need to be involved in making the decision of > if the bitmap index scan should tuck away a carbon copy of the > resulting TIDBitmap after the first scan. That way on rescan we could > just make a copy of the cached versi

Re: Bitmap reuse

2021-07-21 Thread David Rowley
On Wed, 21 Jul 2021 at 13:32, Tom Lane wrote: > > David Rowley writes: > > I imagined Jeff was meaning the bitmap from the scan of foo_x_idx, not > > the combined ANDed bitmap from both indexes. > > To re-use that, you'd need a way to prevent the upper node from > destructively modifying the tidb

Re: Bitmap reuse

2021-07-20 Thread Tom Lane
David Rowley writes: > On Wed, 21 Jul 2021 at 11:25, Tom Lane wrote: >> Uh it's not the "exact same bitmap each time", because the selected >> rows vary depending on the value of g.i. > I imagined Jeff was meaning the bitmap from the scan of foo_x_idx, not > the combined ANDed bitmap from b

Re: Bitmap reuse

2021-07-20 Thread David Rowley
On Wed, 21 Jul 2021 at 11:25, Tom Lane wrote: > > Jeff Janes writes: > > For some queries PostgreSQL can spend most of its time creating the exact > > same bitmap over and over. For example, in the below case: (also attached > > as a file because line-wrapping is going to make a mess of it) > >

Bitmap reuse

2021-07-20 Thread Jeff Janes
For some queries PostgreSQL can spend most of its time creating the exact same bitmap over and over. For example, in the below case: (also attached as a file because line-wrapping is going to make a mess of it) drop table if exists foo; create table foo (x daterange, i int, t text); insert into f

Re: Bitmap reuse

2021-07-20 Thread Tom Lane
Jeff Janes writes: > For some queries PostgreSQL can spend most of its time creating the exact > same bitmap over and over. For example, in the below case: (also attached > as a file because line-wrapping is going to make a mess of it) Uh it's not the "exact same bitmap each time", because