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 C3E859F931E for ; Mon, 8 May 2006 14:50:33 -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 64664-06 for ; Mon, 8 May 2006 14:50:16 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) by postgresql.org (Postfix) with ESMTP id EC58C9F931D for ; Mon, 8 May 2006 14:50:15 -0300 (ADT) Received: by noel.decibel.org (Postfix, from userid 1001) id C826D56435; Mon, 8 May 2006 12:50:14 -0500 (CDT) Received: (hashcash-sendmail, from uid 1001); Mon, 8 May 2006 12:50:13 -0500 Date: Mon, 8 May 2006 12:50:13 -0500 From: "Jim C. Nasby" To: Mark Lewis Cc: Jeffrey Tenny , pgsql-performance@postgresql.org Subject: Re: performance question (something to do w/ Message-ID: <20060508175013.GY99570@pervasive.com> References: <445F7FF8.6070707@comcast.net> <1147110142.32369.7.camel@archimedes> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1147110142.32369.7.camel@archimedes> X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.11 X-Hashcash: 1:20:060508:mark.lewis@mir3.com::LgCb+42IFy0ipc25:000000000000000000 0000000000000000000000001hGX X-Hashcash: 1:20:060508:jeffrey.tenny@comcast.net::YhnYaaAvuDDGuLMj:000000000000 0000000000000000000000008X7s X-Hashcash: 1:20:060508:pgsql-performance@postgresql.org::cXNYVuvuojCNTM0F:00000 0000000000000000000000004ZF8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/145 X-Sequence-Number: 18932 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? -- Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com Pervasive Software http://pervasive.com work: 512-231-6117 vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461