pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Joe Conway <mail@joeconway.com>
Cc: Richard Jones <rich@annexia.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: Very large IN-clause is slow, but how to rewrite it?
Date: Sun, 25 Feb 2007 13:34:44 -0500
Message-ID: <9473.1172428484@sss.pgh.pa.us> (raw)
In-Reply-To: <45E1D4FC.4050901@joeconway.com>
References: <20070225123913.GA17124@furbychan.cocan.org>
	<7794.1172422591@sss.pgh.pa.us>
	<45E1D4FC.4050901@joeconway.com>

Joe Conway <mail@joeconway.com> writes:
> If 8.2, what about
>    ... WHERE foo IN (select x from (values (1$),(2$),...,(N$)) as t(x))
> ?

Well, the OP wasn't using 8.2 --- judging from the selected plan, it had
to be 8.0 or older.  But yeah, a values-list is an interesting
alternative on 8.2.  I think actually you don't need all that much extra
notation; this seems to work:

	WHERE foo IN (VALUES ($1),($2),($3),...)

			regards, tom lane



view thread (6+ messages)  latest in thread

Message-ID: <9473.1172428484@sss.pgh.pa.us>
Permalink:  ../9473.1172428484@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/9473.1172428484@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mail@joeconway.com, rich@annexia.org
  Subject: Re: Very large IN-clause is slow, but how to rewrite it?
  In-Reply-To: <9473.1172428484@sss.pgh.pa.us>

* 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