X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 240AD9FB2EA for ; Tue, 15 Aug 2006 11:17:28 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 66979-02 for ; Tue, 15 Aug 2006 14:17:19 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id 371529FB2DB for ; Tue, 15 Aug 2006 11:17:19 -0300 (ADT) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1GCzvV-0007h8-TB for pgsql-sql@postgresql.org; Tue, 15 Aug 2006 10:29:54 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 4159D4172; Tue, 15 Aug 2006 10:17:12 -0400 (EDT) Date: Tue, 15 Aug 2006 10:17:12 -0400 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Multiple DB join Message-ID: <20060815141712.GB21939@phlogiston.dyndns.org> References: <44E0EA72.2090505@indiana.edu> <20060815103624.GA21634@phlogiston.dyndns.org> <44E1D61D.4020400@indiana.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <44E1D61D.4020400@indiana.edu> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.135 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200608/110 X-Sequence-Number: 26068 On Tue, Aug 15, 2006 at 10:11:41AM -0400, Sumeet Ambre wrote: > > > The Design of the database is because our organization wants to split up > different datasets into different entities, and there might be a > possibility that they'll run different instances of postgres for each > dataset. It's this "different instances" thing that I'm having a tough time with. Is this because they want to be able to query local things when disconnected or something? I can think of applications for this, for sure, I'm just suggesting that you make sure you're not building an optimisation that is (1) premature and (2) possibly a pessimal operation. > records, the query runs damn slow.......below is the sample schema for > my base table and the query i try to run on it....it takes me more than > 2-3 minutes to run a query....Is there any way i could speed this up...... The problem is not your design, nor even the size of the data exactly, but the query: > e.g. SELECT * FROM base WHERE ((title ILIKE '%something%') AND (authors > ~* '.*something.*') AND (db_name='something')); You have two initially-unbound search terms there: ILIKE '%' and ~* '.*' are automatically seqscans, because you have nowhere in the index to start. If you really want to do this kind of unbound-string query, you need to look into full text search. The above approach is never going to be fast. -- Andrew Sullivan | ajs@crankycanuck.ca This work was visionary and imaginative, and goes to show that visionary and imaginative work need not end up well. --Dennis Ritchie