X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 697E9D921C; Fri, 23 Sep 2005 14:43:13 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34397-01; Fri, 23 Sep 2005 17:43:10 +0000 (GMT) Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) by svr1.postgresql.org (Postfix) with ESMTP id 82DDDD90C1; Fri, 23 Sep 2005 14:43:07 -0300 (ADT) Received: from archimedes ([172.16.2.68]) by mir3-fs.mir3.com with Microsoft SMTPSVC(5.0.2195.6713); Fri, 23 Sep 2005 10:46:15 -0700 Subject: Re: [PERFORM] Releasing memory during External sorting? From: Mark Lewis To: Tom Lane Cc: Ron Peacetree , Simon Riggs , pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org In-Reply-To: <5021.1127495844@sss.pgh.pa.us> References: <2559192.1127494115558.JavaMail.root@elwamui-huard.atl.sa.earthlink.net> <5021.1127495844@sss.pgh.pa.us> Content-Type: text/plain Organization: MIR3, Inc. Date: Fri, 23 Sep 2005 10:43:02 -0700 Message-Id: <1127497383.23567.218.camel@archimedes> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-16.3) Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 23 Sep 2005 17:46:15.0535 (UTC) FILETIME=[B1FE2FF0:01C5C066] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.057] X-Spam-Level: X-Archive-Number: 200509/1034 X-Sequence-Number: 73431 operations != passes. If you were clever, you could probably write a modified bubble-sort algorithm that only made 2 passes. A pass is a disk scan, operations are then performed (hopefully in memory) on what you read from the disk. So there's no theoretical log N lower-bound on the number of disk passes. Not that I have anything else useful to add to this discussion, just a tidbit I remembered from my CS classes back in college :) -- Mark On Fri, 2005-09-23 at 13:17 -0400, Tom Lane wrote: > Ron Peacetree writes: > > 2= No optimal external sorting algorithm should use more than 2 passes. > > 3= Optimal external sorting algorithms should use 1 pass if at all possible. > > A comparison-based sort must use at least N log N operations, so it > would appear to me that if you haven't got approximately log N passes > then your algorithm doesn't work. > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match