Re: IN vs EXIIST - Mailing list pgsql-general

From Jean-Christian Imbeault
Subject Re: IN vs EXIIST
Date
Msg-id 3D898177.2070001@mega-bucks.co.jp
Whole thread Raw
In response to IN vs EXIIST  (Jean-Christian Imbeault <jc@mega-bucks.co.jp>)
List pgsql-general
Bill Gribble wrote:

 >I just did this today for a query and got a 200x speedup when
 >converting from IN to EXISTS.  It's dependent on your specific query
 >exactly how to do the conversion, but generally it's just a question
of >moving a field from the "outside" to the "inside" of the subselect.

If it's not asking too much could you recommend how I could fix this
query? It's a bit more complicated than yours and I can't seem to get
the syntax right.

select distinct invoice_id from invoice_li where received='true'
AND shipped='false' AND cancelled='false'
AND
  (invoice_id not in
    (
     select distinct invoice_id from invoice_li where received='false'
AND cancelled='false'
     )
    OR ship_now='true'
    )

Sorry for the formatting ...

Jc


pgsql-general by date:

Previous
From: Wim
Date:
Subject: Re: [ADMIN] Still big problems with pg_dump!
Next
From: Jean-Christian Imbeault
Date:
Subject: datetime(): Where is it in the docs?