On Wed, 21 Jul 2021 at 11:25, Tom Lane <t...@sss.pgh.pa.us> wrote: > > Jeff Janes <jeff.ja...@gmail.com> 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 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 both indexes. I didn't look in detail, but I'd think it would just be a matter of caching the bitmap then in ExecReScanBitmapIndexScan(), if the PlanState's chgParam indicate a parameter has changed, then throw away the cache. Then if the cache is still valid in MultiExecBitmapIndexScan(), return it. Not too sure about the memory context part for the cache. As I said, I didn't look in detail. David