Simon Riggs <simon@2ndquadrant.com> writes:
> On 4 November 2015 at 15:54, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> We generate this plan
> Index Scan using f_x_y_idx on f (cost=0.42..26075.71 rows=209 width=37)
> Index Cond: (x = 5)
> Filter: (y ~~ '%abc%'::text)
> So it should be possible to do the Filter condition on the BitmapIndexScan.
You're missing my point: that is possible in an indexscan, but *not* in a
bitmap indexscan, because the index AM APIs are totally different in the
two cases. In a bitmap scan, nothing more than a TID bitmap is ever
returned out to anyplace that could execute arbitrary expressions.
In the case at hand, the planner should have considered a plan of this
shape as well. Presumably it concluded it was more expensive than using
the bitmap approach. Jeff might try "set enable_bitmapscan = 0" and
compare the estimated and actual costs.
regards, tom lane