Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-performancepgsql-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

pgsql-performance by date

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

pgsql-sql by date

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

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group