X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 465919F931E for ; Mon, 8 May 2006 15:00:20 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 63255-09 for ; Mon, 8 May 2006 15:00:10 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id BEB879F931D for ; Mon, 8 May 2006 15:00:09 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k48HxvRc028289; Mon, 8 May 2006 13:59:57 -0400 (EDT) To: "Jim C. Nasby" cc: Mark Lewis , Jeffrey Tenny , pgsql-performance@postgresql.org Subject: Re: performance question (something to do w/ In-reply-to: <20060508175013.GY99570@pervasive.com> References: <445F7FF8.6070707@comcast.net> <1147110142.32369.7.camel@archimedes> <20060508175013.GY99570@pervasive.com> Comments: In-reply-to "Jim C. Nasby" message dated "Mon, 08 May 2006 12:50:13 -0500" Date: Mon, 08 May 2006 13:59:56 -0400 Message-ID: <28288.1147111196@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/146 X-Sequence-Number: 18933 "Jim C. Nasby" writes: > On Mon, May 08, 2006 at 10:42:21AM -0700, Mark Lewis wrote: >> Doing a SELECT with a large list of variables inside an IN runs slowly >> on every database we've tested. We've tested mostly in Oracle and >> PostgreSQL, and both get very slow very quickly (actually Oracle refuses >> to process the query at all after it gets too many bind parameters). >> >> In our case, we have a (potentially quite large) set of external values >> that we want to look up in the database. We originally thought that >> doing a single select with a large IN clause was the way to go, but then >> we did some performance analysis on the optimal batch size (number of >> items to include per IN clause), and discovered that for most databases, >> the optimal batch size was 1. For PostgreSQL I think it was 2. >> >> The moral of the story is that you're probably better off running a >> bunch of small selects than in trying to optimize things with one >> gargantuan select. > Ever experiment with loading the parameters into a temp table and > joining to that? Also, it might be worth re-testing that conclusion with PG CVS tip (or 8.2 when it comes out). The reimplementation of IN as = ANY that I did a couple months ago might well change the results. regards, tom lane