Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 2C8006326B5 for ; Thu, 19 Aug 2010 10:29:49 -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 73818-02 for ; Thu, 19 Aug 2010 13:29:42 +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 C5B97632915 for ; Thu, 19 Aug 2010 10:29:41 -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 o7JDTdxH026185; Thu, 19 Aug 2010 09:29:39 -0400 (EDT) To: Samuel Gendler cc: pgsql-performance@postgresql.org Subject: Re: in-memory sorting In-reply-to: References: Comments: In-reply-to Samuel Gendler message dated "Wed, 18 Aug 2010 22:45:58 -0700" Date: Thu, 19 Aug 2010 09:29:39 -0400 Message-ID: <26184.1282224579@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: 201008/230 X-Sequence-Number: 40073 Samuel Gendler writes: > Answered my own question. Cranking work_mem up to 350MB revealed that > the in-memory sort requires more memory than the disk sort. Yeah. The on-disk representation of sortable data is tighter than the in-memory representation for various reasons, mostly that we're willing to work at making it small. Datums aren't necessarily properly aligned for example, and there's also palloc overhead to consider in-memory. regards, tom lane