Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id C0766B5D80A for ; Thu, 27 Oct 2011 19:19:58 -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 12048-01 for ; Thu, 27 Oct 2011 22:19:52 +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 22C99B5DC1F for ; Thu, 27 Oct 2011 19:19:52 -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 p9RMJkqY007240; Thu, 27 Oct 2011 18:19:47 -0400 (EDT) To: sthomas@peak6.com cc: Robert Haas , Giovanni Mancuso , pgsql-performance@postgresql.org Subject: Re: Performance problem with a table with 38928077 record In-reply-to: <4EA9BF84.3000203@peak6.com> References: <4E8ECEB7.4080800@babel.it> <4EA9BF84.3000203@peak6.com> Comments: In-reply-to Shaun Thomas message dated "Thu, 27 Oct 2011 15:31:00 -0500" Date: Thu, 27 Oct 2011 18:19:46 -0400 Message-ID: <7239.1319753986@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201110/237 X-Sequence-Number: 45459 Shaun Thomas writes: > On 10/27/2011 02:13 PM, Robert Haas wrote: >> If I had to guess, I'd bet that the second one is trying to spool the >> resultset in memory someplace and that's driving the machine into >> swap. > That would be my guess too. SELECT * on a 40-million row table is a > *lot* different than getting the count, which throws away the rows once > it verifies they're valid. But EXPLAIN ANALYZE throws away the rows too. There's something odd going on there, but the information provided is insufficient to tell what. regards, tom lane