Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 62499B5DC32 for ; Wed, 2 Nov 2011 20:53:12 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 88898-01 for ; Wed, 2 Nov 2011 23:53:04 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 32C15B5DC2B for ; Wed, 2 Nov 2011 20:53:04 -0300 (ADT) 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 pA2Nr2Ox029295; Wed, 2 Nov 2011 19:53:03 -0400 (EDT) To: Brian Fehrle cc: pgsql-performance@postgresql.org Subject: Re: two table join just not fast enough. In-reply-to: <4EB1A419.1080901@consistentstate.com> References: <4EB1A419.1080901@consistentstate.com> Comments: In-reply-to Brian Fehrle message dated "Wed, 02 Nov 2011 14:12:09 -0600" Date: Wed, 02 Nov 2011 19:53:02 -0400 Message-ID: <29294.1320277982@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.101 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.201 X-Spam-Level: X-Archive-Number: 201111/33 X-Sequence-Number: 45544 Brian Fehrle writes: > I've got a query that I need to squeeze as much speed out of as I can. Hmm ... are you really sure this is being run with work_mem = 50MB? The hash join is getting "batched", which means the executor thinks it's working under a memory constraint significantly less than the size of the filtered inner relation, which should be no more than a couple megabytes according to this. I'm not sure how much that will save, since the hashjoin seems to be reasonably speedy anyway, but there's not much other fat to trim here. One minor suggestion is to think whether you really need string comparisons here or could convert that to use of an enum type. String compares ain't cheap, especially not in non-C locales. regards, tom lane