Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

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



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



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group