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 6B151D7283; Fri, 30 Sep 2005 01:22:50 -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 33766-07; Fri, 30 Sep 2005 04:22:45 +0000 (GMT) Received: from mail.mi8.com (d01gw04.mi8.com [63.240.6.44]) by svr1.postgresql.org (Postfix) with ESMTP id 146FBD6F2C; Fri, 30 Sep 2005 01:22:39 -0300 (ADT) Received: from 172.16.1.110 by mail.mi8.com with ESMTP (- Welcome to Mi8 Corporation www.Mi8.com (D4)); Fri, 30 Sep 2005 00:22:29 -0400 X-Server-Uuid: C8FB4D43-1108-484A-A898-3CBCC7906230 Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.175]) by D01SMTP01.Mi8.com with Microsoft SMTPSVC(6.0.3790.211); Fri, 30 Sep 2005 00:22:29 -0400 Received: from 69.181.100.71 ([69.181.100.71]) by MI8NYCMAIL06.Mi8.com ( [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Fri, 30 Sep 2005 00:22:28 -0500 User-Agent: Microsoft-Entourage/11.2.0.050811 Date: Thu, 29 Sep 2005 21:22:27 -0700 Subject: Re: [PERFORM] A Better External Sort? From: "Luke Lonergan" To: "Jeffrey W. Baker" Cc: "Josh Berkus" , "Ron Peacetree" , pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org Message-ID: Thread-Topic: [HACKERS] [PERFORM] A Better External Sort? Thread-Index: AcXFdpBwzwcGjTFpEdqrvAANk63kWA== In-Reply-To: <1128015863.11474.9.camel@noodles> MIME-Version: 1.0 X-OriginalArrivalTime: 30 Sep 2005 04:22:29.0198 (UTC) FILETIME=[91BF66E0:01C5C576] X-WSS-ID: 6F22620F34O2388611-01-01 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.531 required=5 tests=[RCVD_NUMERIC_HELO=1.531] X-Spam-Level: * X-Archive-Number: 200509/1395 X-Sequence-Number: 73792 Jeff, On 9/29/05 10:44 AM, "Jeffrey W. Baker" wrote: > On Thu, 2005-09-29 at 10:06 -0700, Luke Lonergan wrote: > Looking through tuplesort.c, I have a couple of initial ideas. Are we > allowed to fork here? That would open up the possibility of using the > CPU and the I/O in parallel. I see that tuplesort.c also suffers from > the kind of postgresql-wide disease of calling all the way up and down a > big stack of software for each tuple individually. Perhaps it could be > changed to work on vectors. Yes! > I think the largest speedup will be to dump the multiphase merge and > merge all tapes in one pass, no matter how large M. Currently M is > capped at 6, so a sort of 60GB with 1GB sort memory needs 13 passes over > the tape. It could be done in a single pass heap merge with N*log(M) > comparisons, and, more importantly, far less input and output. Yes again, see above. > I would also recommend using an external processes to asynchronously > feed the tuples into the heap during the merge. Simon Riggs is working this idea a bit - it's slightly less interesting to us because we already have a multiprocessing executor. Our problem is that 4 x slow is still far too slow. > What's the timeframe for 8.2? Let's test it out in Bizgres! - Luke