Re: Postgres Optimizer is not smart enough? - Mailing list pgsql-performance

From Tom Lane
Subject Re: Postgres Optimizer is not smart enough?
Date
Msg-id 9156.1105629851@sss.pgh.pa.us
Whole thread Raw
In response to Re: Postgres Optimizer is not smart enough?  (Mark Kirkwood <markir@coretech.co.nz>)
List pgsql-performance
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

pgsql-performance by date:

Previous
From: Joe Conway
Date:
Subject: Re: PostgreSQL vs. Oracle vs. Microsoft
Next
From: William Yu
Date:
Subject: Re: Increasing RAM for more than 4 Gb. using postgresql