X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 23D4F9DCB0B for ; Thu, 15 Dec 2005 07:02:08 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69293-02 for ; Thu, 15 Dec 2005 07:02:10 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail5.dslextreme.com (mail5.dslextreme.com [66.51.199.81]) by postgresql.org (Postfix) with SMTP id 941CC9DCB34 for ; Thu, 15 Dec 2005 07:02:04 -0400 (AST) Received: (qmail 17528 invoked from network); 15 Dec 2005 11:01:28 -0000 Received: from unknown (HELO [10.1.1.1]) (mitchskin@66.245.216.230) by mail5.dslextreme.com with SMTP; Thu, 15 Dec 2005 03:01:28 -0800 Subject: Re: Simple Join From: Mitch Skinner To: Kevin Brown Cc: pgsql-performance@postgresql.org In-Reply-To: <200512150148.16125.blargity@gmail.com> References: <200512141603.52583.blargity@gmail.com> <7484.1134600423@sss.pgh.pa.us> <1134629567.14248.27.camel@firebolt> <200512150148.16125.blargity@gmail.com> Content-Type: text/plain Date: Thu, 15 Dec 2005 03:02:06 -0800 Message-Id: <1134644526.14248.60.camel@firebolt> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200512/353 X-Sequence-Number: 16174 On Thu, 2005-12-15 at 01:48 -0600, Kevin Brown wrote: > > Well, I'm no expert either, but if there was an index on > > ordered_products (paid, suspended_sub, id) it should be mergejoinable > > with the index on to_ship.ordered_product_id, right? Given the > > conditions on paid and suspended_sub. > > > The following is already there: > > CREATE INDEX ordered_product_id_index > ON to_ship > USING btree > (ordered_product_id); > > That's why I emailed this list. I saw that; what I'm suggesting is that that you try creating a 3-column index on ordered_products using the paid, suspended_sub, and id columns. In that order, I think, although you could also try the reverse. It may or may not help, but it's worth a shot--the fact that all of those columns are used together in the query suggests that you might do better with a three-column index on those. With all three columns indexed individually, you're apparently not getting the bitmap plan that Mark is hoping for. I imagine this has to do with the lack of multi-column statistics in postgres, though you could also try raising the statistics target on the columns of interest. Setting enable_seqscan to off, as others have suggested, is also a worthwhile experiment, just to see what you get. Mitch