Mark Kirkwood <markir@coretech.co.nz> writes:
> Hmmm ... so it's only the selectivity that is the same (sourced from
> index->amcostestimate which I am guessing points to btcostestimate), is
> that correct?
No, the point is that btcostestimate will compute not only the same
selectivities but the identical index access cost values, because it
thinks that only one index entry will be fetched in both cases. It
needs to account for the fact that the inequality condition will cause a
scan over a larger range of the index than is actually returned. See
_bt_preprocess_keys() and _bt_checkkeys().
The small differences you are showing have to do with different
assumptions about where the now() function will get evaluated (once per
row or once at scan start). That's not the effect that I'm worried
about.
regards, tom lane