Re: Postgres Optimizer is not smart enough?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mark Kirkwood <markir(at)coretech(dot)co(dot)nz>
Cc: Litao Wu <litaowu(at)yahoo(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Postgres Optimizer is not smart enough?
Date: 2005-01-13 15:24:11
Message-ID: 9156.1105629851@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Mark Kirkwood <markir(at)coretech(dot)co(dot)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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message William Yu 2005-01-13 16:32:49 Re: Increasing RAM for more than 4 Gb. using postgresql
Previous Message Joe Conway 2005-01-13 14:56:52 Re: PostgreSQL vs. Oracle vs. Microsoft