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 3F98E9FA293; Tue, 9 May 2006 06:32:56 -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 33127-04; Tue, 9 May 2006 06:32:45 -0300 (ADT) X-Greylist: delayed 00:31:32.174214 by SQLgrey- X-Greylist: from auto-whitelisted by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 6D0E39F931D; Tue, 9 May 2006 06:32:46 -0300 (ADT) Received: from mx11.cksoft.de (mx11.cksoft.de [62.111.66.11]) by svr4.postgresql.org (Postfix) with ESMTP id 19D7C5B2637; Tue, 9 May 2006 09:01:11 +0000 (GMT) Received: from vesihiisi.cksoft.de (unknown [192.168.64.10]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by mx12.cksoft.de (Postfix) with ESMTP id 7A977B99F; Tue, 9 May 2006 11:01:07 +0200 (CEST) Received: from vesihiisi.cksoft.de (localhost [127.0.0.1]) by vesihiisi.cksoft.de (Postfix) with ESMTP id A7EF81EA3; Tue, 9 May 2006 11:01:05 +0200 (CEST) Received: by vesihiisi.cksoft.de (Postfix, from userid 1000) id EC5441EA1; Tue, 9 May 2006 11:01:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by vesihiisi.cksoft.de (Postfix) with ESMTP id E3CBD1E9C; Tue, 9 May 2006 11:01:00 +0200 (CEST) Date: Tue, 9 May 2006 11:01:00 +0200 (CEST) From: Christian Kratzer X-X-Sender: ck@vesihiisi.cksoft.de Reply-To: Christian Kratzer To: PFC Cc: Tom Lane , pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: Big IN() clauses etc : feature proposal In-Reply-To: Message-ID: <20060509105214.P90693@vesihiisi.cksoft.de> References: <445F7FF8.6070707@comcast.net> <1147110142.32369.7.camel@archimedes> <20060508175013.GY99570@pervasive.com> <28288.1147111196@sss.pgh.pa.us> X-Spammer-Kill-Ratio: 75% MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by AMaViS cksoft-s20020300-20031204bz on vesihiisi.cksoft.de X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/171 X-Sequence-Number: 18958 Hi, On Tue, 9 May 2006, PFC wrote: > Back to the point : I can't use the temp table method, because temp > tables are too slow. > Creating a temp table, filling it, analyzing it and then dropping it > takes about 100 ms. The search query, on average, takes 10 ms. just some thoughts: You might consider just selecting your primary key or a set of primary keys to involved relations in your search query. If you currently use "select *" this can make your result set very large. Copying all the result set to the temp. costs you additional IO that you propably dont need. Also you might try: SELECT * FROM somewhere JOIN result USING (id) Instead of: SELECT * FROM somewhere WHERE id IN (SELECT id FROM result) Joins should be a lot faster than large IN clauses. Here it will also help if result only contains the primary keys and not all the other data. The join will be much faster. On the other hand if your search query runs in 10ms it seems to be fast enough for you to run it multiple times. Theres propably no point in optimizing anything in such case. Greetings Christian -- Christian Kratzer ck@cksoft.de CK Software GmbH http://www.cksoft.de/ Phone: +49 7452 889 135 Fax: +49 7452 889 136