Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 17B30B5DF89 for ; Wed, 8 Jun 2011 12:33:14 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 33230-08 for ; Wed, 8 Jun 2011 15:33:07 +0000 (UTC) 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 D0A19B5DF80 for ; Wed, 8 Jun 2011 12:33:06 -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 p58FX50U010261; Wed, 8 Jun 2011 11:33:05 -0400 (EDT) To: Tony Capobianco cc: pgsql-performance@postgresql.org Subject: Re: Oracle v. Postgres 9.0 query performance In-reply-to: <1307545892.1990.23.camel@tony1.localdomain> References: <1307545892.1990.23.camel@tony1.localdomain> Comments: In-reply-to Tony Capobianco message dated "Wed, 08 Jun 2011 11:11:32 -0400" Date: Wed, 08 Jun 2011 11:33:05 -0400 Message-ID: <10260.1307547185@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/69 X-Sequence-Number: 44002 Tony Capobianco writes: > pg_dw=# explain CREATE TABLE ecr_opens with (FILLFACTOR=100) > pg_dw-# as > pg_dw-# select o.emailcampaignid, count(memberid) opencnt > pg_dw-# from openactivity o,ecr_sents s > pg_dw-# where s.emailcampaignid = o.emailcampaignid > pg_dw-# group by o.emailcampaignid; > QUERY > PLAN > ------------------------------------------------------------------------------------------------------------- > GroupAggregate (cost=0.00..1788988.05 rows=9939 width=12) > -> Nested Loop (cost=0.00..1742467.24 rows=9279316 width=12) > -> Index Scan using ecr_sents_ecid_idx on ecr_sents s > (cost=0.00..38.59 rows=479 width=4) > -> Index Scan using openact_emcamp_idx on openactivity o > (cost=0.00..3395.49 rows=19372 width=12) > Index Cond: (o.emailcampaignid = s.emailcampaignid) > (5 rows) > Should this query be hashing the smaller table on Postgres rather than > using nested loops? Yeah, seems like it. Just for testing purposes, do "set enable_nestloop = 0" and see what plan you get then. regards, tom lane