| From: | Richard Huxton <dev(at)archonet(dot)com> | 
|---|---|
| To: | "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com>, pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: how to make query more efficient? | 
| Date: | 2003-03-19 19:11:26 | 
| Message-ID: | 200303191911.26641.dev@archonet.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Huxton | 2003-03-19 19:17:41 | Re: Error loading /usr/lib/postgresql/plpgsql.so | 
| Previous Message | Miguel Angel Martin | 2003-03-19 18:55:19 | ¿What's wrong? |