Re: Postgres optimizer choosing wrong index

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jack Orenstein <jack(dot)orenstein(at)hds(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Postgres optimizer choosing wrong index
Date: 2008-10-27 22:47:21
Message-ID: 26231.1225147641@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jack Orenstein <jack(dot)orenstein(at)hds(dot)com> writes:
> EXPLAIN says that the correct index is being used -- it didn't used
> to. However, pg_stat* says otherwise. In my test, I have exactly one
> dh value. Running EXPLAIN with this value produces a plan using idx_dh
> (the correct index), but pg_stats says that idx_dn is being used (see
> psql session below).

Yeah, if you are using cached plans (via PREPARE or plpgsql functions)
then the plan stays the same for the life of the session ... pre 8.3
that is.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-10-27 22:57:43 Re: PostgreSQL 8.3.3 chooses wrong query plan when LIMIT 1 added?
Previous Message Mark Cave-Ayland 2008-10-27 22:24:30 Re: PostgreSQL 8.3.3 chooses wrong query plan when LIMIT 1 added?