On Wed, 21 Jul 2021 at 13:32, Tom Lane <t...@sss.pgh.pa.us> wrote: > > David Rowley <dgrowle...@gmail.com> 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 tidbitmap.
Yeah. And that would slow things down in the case where it was just executed once as we'd need to make a copy of it to prevent the cached version from being modified regardless if it would ever be used again or not. 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 version and return that. That saves having to modify the callers to tell them not to damage the returned TIDBitmap. David