Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id A4AB41337B61 for ; Wed, 17 Nov 2010 19:21:27 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 40504-05 for ; Wed, 17 Nov 2010 23:21:20 +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 002BD1337B58 for ; Wed, 17 Nov 2010 19:21:19 -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 oAHNLI7j026559; Wed, 17 Nov 2010 18:21:18 -0500 (EST) To: Humair Mohammed cc: pavel.stehule@gmail.com, pgsql-performance@postgresql.org Subject: Re: Query Performance SQL Server vs. Postgresql In-reply-to: References: , , Comments: In-reply-to Humair Mohammed message dated "Wed, 17 Nov 2010 15:50:25 -0600" Date: Wed, 17 Nov 2010 18:21:18 -0500 Message-ID: <26558.1290036078@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: 201011/307 X-Sequence-Number: 41331 Humair Mohammed writes: > Yes strange indeed, I did rerun ANALYZE and VACCUM. Took 70 seconds to rerun the query. Results from EXPLAIN ANALYZE below: > "Hash Join (cost=16212.30..52586.43 rows=92869 width=17) (actual time=43200.223..49502.874 rows=3163 loops=1)"" Hash Cond: (((pb.id)::text = (pg.id)::text) AND ((pb.question)::text = (pg.question)::text))"" Join Filter: ((COALESCE(pb.response, 'MISSING'::character varying))::text <> (COALESCE(pg.response, 'MISSING'::character varying))::text)"" -> Seq Scan on pivotbad pb (cost=0.00..2804.96 rows=93496 width=134) (actual time=0.009..48.200 rows=93496 loops=1)"" -> Hash (cost=7537.12..7537.12 rows=251212 width=134) (actual time=42919.453..42919.453 rows=251212 loops=1)"" Buckets: 1024 Batches: 64 Memory Usage: 650kB"" -> Seq Scan on pivotgood pg (cost=0.00..7537.12 rows=251212 width=134) (actual time=0.119..173.019 rows=251212 loops=1)""Total runtime: 49503.450 ms" I have no idea how much memory SQL Server thinks it can use, but Postgres is limiting itself to work_mem which you've apparently left at the default 1MB. You might get a fairer comparison by bumping that up some --- try 32MB or so. You want it high enough so that the Hash output doesn't say there are multiple batches. regards, tom lane