Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 468F8B5D94C for ; Wed, 8 Jun 2011 12:52:08 -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 51426-06-2 for ; Wed, 8 Jun 2011 15:52:01 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from tamriel.snowman.net (tamriel.snowman.net [72.66.115.51]) by mail.postgresql.org (Postfix) with ESMTP id 23A01B5DF92 for ; Wed, 8 Jun 2011 12:52:01 -0300 (ADT) Received: by tamriel.snowman.net (Postfix, from userid 1000) id DBF7A2296E; Wed, 8 Jun 2011 11:51:59 -0400 (EDT) Date: Wed, 8 Jun 2011 11:51:59 -0400 From: Stephen Frost To: Tony Capobianco Cc: Tom Lane , pgsql-performance@postgresql.org Subject: Re: Oracle v. Postgres 9.0 query performance Message-ID: <20110608155159.GA18128@tamriel.snowman.net> References: <1307545892.1990.23.camel@tony1.localdomain> <10260.1307547185@sss.pgh.pa.us> <1307547634.1990.26.camel@tony1.localdomain> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="dOtxUVmLoGkyu1PA" Content-Disposition: inline In-Reply-To: <1307547634.1990.26.camel@tony1.localdomain> X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/2.6.32-5-amd64 (x86_64) X-Uptime: 11:49:48 up 126 days, 19 min, 21 users, load average: 0.00, 0.02, 0.00 User-Agent: Mutt/1.5.20 (2009-06-14) 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/71 X-Sequence-Number: 44004 --dOtxUVmLoGkyu1PA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Tony Capobianco (tcapobianco@prospectiv.com) wrote: > HashAggregate (cost=3D4391163.81..4391288.05 rows=3D9939 width=3D12) > -> Hash Join (cost=3D14.78..4344767.23 rows=3D9279316 width=3D12) > Hash Cond: (o.emailcampaignid =3D s.emailcampaignid) > -> Seq Scan on openactivity o (cost=3D0.00..3529930.67 > rows=3D192540967 width=3D12) > -> Hash (cost=3D8.79..8.79 rows=3D479 width=3D4) > -> Seq Scan on ecr_sents s (cost=3D0.00..8.79 rows=3D479 > width=3D4) >=20 > Yikes. Two sequential scans. Err, isn't that more-or-less exactly what you want here? The smaller table is going to be hashed and then you'll traverse the bigger table and bounce each row off the hash table. Have you tried actually running this and seeing how long it takes? The bigger table doesn't look to be *that* big, if your i/o subsystem is decent and you've got a lot of memory available for kernel cacheing, should be quick. Thanks, Stephen --dOtxUVmLoGkyu1PA Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAk3vmp8ACgkQrzgMPqB3kiiZmQCeLMtcY2+HngSVHHCPgp8eGlAX rSMAmwaWYBmExG+oHqlOI3E5nDNFtTjn =f3nB -----END PGP SIGNATURE----- --dOtxUVmLoGkyu1PA--