Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 58EBF6502D8 for ; Fri, 21 Nov 2008 16:07:16 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 66920-02 for ; Fri, 21 Nov 2008 16:07:13 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 4221F6502E9 for ; Fri, 21 Nov 2008 16:07:12 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id mALK72bo011836; Fri, 21 Nov 2008 15:07:02 -0500 (EST) To: PFC cc: Andrus , "Richard Huxton" , pgsql-performance@postgresql.org Subject: Re: Hash join on int takes 8..114 seconds In-reply-to: References: <49253FE1.3070706@archonet.com> <0205611B528C4C2CBA99AFC64E57D6E8@andrusnotebook> <75A918DFCF25470FAF96B3FE3D25A38B@andrusnotebook> Comments: In-reply-to PFC message dated "Fri, 21 Nov 2008 19:31:42 +0100" Date: Fri, 21 Nov 2008 15:07:02 -0500 Message-ID: <11835.1227298022@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200811/193 X-Sequence-Number: 31924 PFC writes: > Index on orders_products( product_id ) and orders_products( order_id ): > => Same plan > Note that in this case, a smarter planner would use the new index to > perform a BitmapAnd before hitting the heap to get the rows. Considering that the query has no constraint on orders_products.order_id, I'm not sure what you think the extra index is supposed to be used *for*. (Well, we could put orders as the outside of a nestloop and then we'd have such a constraint, but with 30000 orders rows to process that plan would lose big.) (And yes, the planner did consider such a plan along the way. See choose_bitmap_and.) regards, tom lane