Re: Very large IN-clause is slow, but how to rewrite it?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: Richard Jones <rich(at)annexia(dot)org>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Very large IN-clause is slow, but how to rewrite it?
Date: 2007-02-25 18:34:44
Message-ID: 9473.1172428484@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Joe Conway <mail(at)joeconway(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Jones 2007-02-25 19:39:05 Re: Very large IN-clause is slow, but how to rewrite it?
Previous Message Joe Conway 2007-02-25 18:27:08 Re: Very large IN-clause is slow, but how to rewrite it?