Re: Problem with planner - Mailing list pgsql-general

From Tom Lane
Subject Re: Problem with planner
Date
Msg-id 13004.1312924718@sss.pgh.pa.us
Whole thread Raw
In response to Re: Problem with planner  (hubert depesz lubaczewski <depesz@depesz.com>)
Responses Re: Problem with planner  (hubert depesz lubaczewski <depesz@depesz.com>)
List pgsql-general
hubert depesz lubaczewski <depesz@depesz.com> writes:
> I solved the problem by adding "enable_bitmapscan = false" (and keeping
> the query in original format, with subselect) which caused the plan to
> be ok.

I doubt that solution is any more robust than what you had before ---
in particular, it's likely to fall back to seqscans.

> but I'm much more interested to understand why pg chooses *not* to use
> index which is tailored specifically for the query - it has exactly
> matching where clause, and it indexes the column that we use for
> comparison.

Because the planner thinks it will have to pull a huge number of rows
from the index.  Whether the index is "tailored" for the query
is irrelevant if it looks more expensive to use than a seqscan.

            regards, tom lane

pgsql-general by date:

Previous
From: hubert depesz lubaczewski
Date:
Subject: Re: Problem with planner
Next
From: Postgres User
Date:
Subject: Indicating DEFAULT values in INSERT statement