Re: Query is not using index when it should - Mailing list pgsql-performance

From Josh Berkus
Subject Re: Query is not using index when it should
Date
Msg-id 200412121848.27513.josh@agliodbs.com
Whole thread Raw
In response to Query is not using index when it should  (tomas@nocrew.org (Tomas Skäre))
List pgsql-performance
Tomas,

> I tried to subscribe to pgsql-performance, but there seems to be
> something wrong with the majordomo, so I'm sending to general too,
> where I'm already subscribed.

Well, I got your e-mail, so obviously you're subscribed to Performance.

> But when doing a search with objectid, class and field, it doesn't use
> the idx_cjm_object1 index.
> db=# explain analyze select * from cjm_object where objectid=4534 and
> class=12 and field='paroid'; QUERY PLAN

Try:

explain analyze select * from cjm_object where objectid=4534::BIGINT and
class=12 and field='paroid';

Sometimes the planner needs a little extra help on BIGINT fields.   This
problem is fixed in 8.0.

--
Josh Berkus
Aglio Database Solutions
San Francisco

pgsql-performance by date:

Previous
From: John A Meinel
Date:
Subject: Re: Config Check
Next
From: Sven Willenberger
Date:
Subject: Using LIMIT changes index used by planner