Re: how to make query more efficient? - Mailing list pgsql-general

From Richard Huxton
Subject Re: how to make query more efficient?
Date
Msg-id 200303191911.26641.dev@archonet.com
Whole thread Raw
In response to how to make query more efficient?  ("Johnson, Shaunn" <SJohnson6@bcbsm.com>)
List pgsql-general
On Wednesday 19 Mar 2003 6:23 pm, Johnson, Shaunn wrote:
> Howdy:
>
> Running PostgreSQL 7.2.1 on RedHat Linux 7.2.
>
> I'm trying to run a query and it seems by using EXPLAIN
> that it will take a long time.  Is there a way to get the
> results in a more efficient manner?  Basically, I want
> a list of records that are NOT in the table ref_person.
>
> [snip query]
> explain
>
> select
...
> from
> ref_person x
> where
> x.contract not in

Try rewriting the IN as an EXISTS clause - PG has traditionally not been too
clever at handling IN (though I believe this is to improve in the next
version).

--
  Richard Huxton

pgsql-general by date:

Previous
From: "Miguel Angel Martin"
Date:
Subject: ¿What's wrong?
Next
From: Richard Huxton
Date:
Subject: Re: Error loading /usr/lib/postgresql/plpgsql.so