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

From Tom Lane
Subject Re: Very large IN-clause is slow, but how to rewrite it?
Date
Msg-id 7794.1172422591@sss.pgh.pa.us
Whole thread Raw
In response to Very large IN-clause is slow, but how to rewrite it?  (Richard Jones <rich@annexia.org>)
Responses Re: Very large IN-clause is slow, but how to rewrite it?  (Joe Conway <mail@joeconway.com>)
List pgsql-sql
Richard Jones <rich@annexia.org> writes:
> I've been profiling a PG database / mix of applications and found that
> one statement which takes a very long time to execute is:

PG 8.2 does better with long IN-lists ... although if the list is so
long as to be fetching a significant fraction of the table, you'll still
have problems.  In that case I'd advise putting the values into a temp
table, ANALYZEing same, and doing "WHERE foo IN (SELECT x FROM tmp_table)".
        regards, tom lane


pgsql-sql by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: Very large IN-clause is slow, but how to rewrite it?
Next
From: Joe Conway
Date:
Subject: Re: Very large IN-clause is slow, but how to rewrite it?