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: Richard Jones <rich(at)annexia(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Very large IN-clause is slow, but how to rewrite it?
Date: 2007-02-25 16:56:31
Message-ID: 7794.1172422591@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Richard Jones <rich(at)annexia(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Joe Conway 2007-02-25 18:27:08 Re: Very large IN-clause is slow, but how to rewrite it?
Previous Message Oleg Bartunov 2007-02-25 14:40:54 Re: Very large IN-clause is slow, but how to rewrite it?