pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Tenny <tenny@attbi.com>
To: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Cc: Bruno Wolff III <bruno@wolff.to>
Cc: Andreas Pflug <Andreas.Pflug@web.de>
Cc: pgsql-performance@postgresql.org
Subject: Re: IN list processing performance (yet again)
Date: Thu, 29 May 2003 08:48:41 -0400
Message-ID: <3ED601A9.50209@attbi.com> (raw)
In-Reply-To: <0b9a01c32585$2a8e6900$6500a8c0@fhp.internal>
References: <3ED4B0E5.3050703@attbi.com>
	<3ED4B75A.2050106@web.de>
	<3ED4FB02.1010908@attbi.com>
	<20030528183914.GA6118@wolff.to>
	<3ED5159E.2050407@attbi.com>
	<0b9a01c32585$2a8e6900$6500a8c0@fhp.internal>

Christopher Kings-Lynne wrote:

>  
>
>>Also, IN (subquery) is a known performance problem in PGSQL, at least if
>>    
>>
>the subquery is going to return > many rows.
>  
>
>>It's too bad, since I'm rather fond of subqueries, but I avoid them like
>>    
>>
>the plague in PostgreSQL.
>
>You're not really using a subquery - really just a long list of integers.
>

Oops, you got that out of context, it was a different piece of 
conversation about subqueries in IN predicate,
not the scalar forms that was my overall discussion point.  You're 
right, I'm using lists of integers,
someone else was suggesting using subqueries in some context and I was 
responding to that.

>Subqueries are lightning fast, so long as you conver to the EXISTS form:
>
>SELECT * FROM tab WHERE id IN (SELECT id2 FROM tab2);
>
>converts to:
>
>SELECT * FROM tab WHERE EXISTS (SELECT id2 FROM tab2 WHERE id2=id);
>
>Chris
>  
>
I hadn't thought of that, it's an excellent tip.  I'll have to remember 
it next time I want to use subqueries.
(Again, it's a side topic, my primary concern is scalar-form IN lists.)

Thanks,

Dave

view thread (23+ messages)

Message-ID: <3ED601A9.50209@attbi.com>
Permalink:  ../3ED601A9.50209@attbi.com/
Also on:    postgresql.org/message-id/3ED601A9.50209@attbi.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: tenny@attbi.com, chriskl@familyhealth.com.au, bruno@wolff.to, Andreas.Pflug@web.de
  Subject: Re: IN list processing performance (yet again)
  In-Reply-To: <3ED601A9.50209@attbi.com>
  References: <3ED4B0E5.3050703@attbi.com> <3ED4B75A.2050106@web.de> <3ED4FB02.1010908@attbi.com> <20030528183914.GA6118@wolff.to> <3ED5159E.2050407@attbi.com> <0b9a01c32585$2a8e6900$6500a8c0@fhp.internal> <3ED601A9.50209@attbi.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox