Re: Query is not using index when it should

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Cc: tomas(at)nocrew(dot)org (Tomas =?iso-8859-1?q?Sk=E4re?=)
Subject: Re: Query is not using index when it should
Date: 2004-12-13 02:48:27
Message-ID: 200412121848.27513.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance pgsql-sql

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lonni J Friedman 2004-12-13 02:51:08 disabling OIDs?
Previous Message Tom Lane 2004-12-13 02:35:33 Re: Temporary tables and disk activity

Browse pgsql-performance by date

  From Date Subject
Next Message Sven Willenberger 2004-12-13 06:13:43 Using LIMIT changes index used by planner
Previous Message Tomas =?iso-8859-1?q?Sk=E4re?= 2004-12-12 08:32:25 Re: [GENERAL] Query is not using index when it should

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 2004-12-13 03:13:42 Re: Unresolved external: tgetent
Previous Message Tom Lane 2004-12-13 02:45:49 Re: parse error at or near "(" -- Huh???