Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Zzudy-0005M4-VF for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Nov 2015 22:59:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Zzudx-0005Rj-GX for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Nov 2015 22:59:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Zzudv-0005Ra-Ri for pgsql-hackers@postgresql.org; Fri, 20 Nov 2015 22:58:59 +0000 Received: from mail-vk0-x234.google.com ([2607:f8b0:400c:c05::234]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Zzuds-0000pJ-6Q for pgsql-hackers@postgresql.org; Fri, 20 Nov 2015 22:58:58 +0000 Received: by vkfr145 with SMTP id r145so7475088vkf.0 for ; Fri, 20 Nov 2015 14:58:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heroku-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=vfbmqR24SEFBRQzcMEW3eE7ELxb7i2XJ1phA71MffCU=; b=I04pohgZ6XjIcspejIo4pVABQnxHH7LnAQOurXHbpt1AJ+yAPaI3YgnmUQTfzs/6kL COH7bVnp19PWKKuq7tI5LCV6/an2/K5iVnDdQPGbwRTCLiSzsP8juyBsfG/zYoS5oTGY QEMiT0f/flfOQwwsVG2cQYfYNtACVTb6GrEVfKquMW/ha3h6rmAuOlqP9i7G+xIwkznU CdAQrRPOfHvYis8JB1OxOxDCaRJ0vxX9Q6YhT7qCPIZaX2+CSbl/W8nwN8x9B7jY+LKZ mU0FamIQrW6Ub7UusigU1kAzFkYWucMup11915/OFX3LGtKPif8p2pAvSRxPqnZ+qDev lWYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=vfbmqR24SEFBRQzcMEW3eE7ELxb7i2XJ1phA71MffCU=; b=fiTLAdteqnUwV2wfmE/dsQ520b4J1lI0ARGVdk2Li2cxwUBKv6pBLLAXPt4lWTGrnk jhyGnD6kVfFQPYZ0gO/i5TZy9rArYWX38TAIy4SOAo3jabCjqoP5r/J5TwZVHaXJTvDz 8+ID+n2EcYwwn4VrPK86mltBjzu70IrtyG/Q/y5CF+c8Ib/ZSeQyKj/1ahOjOApOb4Gi uhU+6LGT1IfVTNe2IfRPT5IFnBsBDEribvPgCBTunzjPMTOPiMqgBBGSYmrDuBavTPP9 IyR0JP2bcWsQLAIFWPX764HDUkZx39rlh3H57TnM82uU3NvQJSq0e1XQB9Dq5PDlXhnX L4Zg== X-Gm-Message-State: ALoCoQl+Tw7zYRmYUlMFBtmuLC5APG5yanv7sN152g8Itn6h4lJenbKIn+Ki7QvfayJHHLD2Jak7 MIME-Version: 1.0 X-Received: by 10.31.41.131 with SMTP id p125mr2106760vkp.133.1448060332669; Fri, 20 Nov 2015 14:58:52 -0800 (PST) Received: by 10.31.189.151 with HTTP; Fri, 20 Nov 2015 14:58:52 -0800 (PST) In-Reply-To: References: Date: Fri, 20 Nov 2015 14:58:52 -0800 Message-ID: Subject: Re: Using quicksort for every external sort run From: Peter Geoghegan To: Robert Haas Cc: Jeff Janes , Pg Hackers , Heikki Linnakangas , Simon Riggs Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On Fri, Nov 20, 2015 at 12:52 PM, Robert Haas wrote: > That's what I was asking about. It seemed to me that you were saying > we could ignore those cases, which doesn't seem to me to be true. I've been around for long enough to know that there are very few cases that can be ignored. :-) >> The latter 16MB work_mem example query/table is still faster with a >> 12MB work_mem than master, even with multiple passes. Quite a bit >> faster, in fact: about 37 seconds on master, to about 24.7 seconds >> with the patches (same for higher settings short of 16MB). > > Is this because we save enough by quicksorting rather than heapsorting > to cover the cost of the additional merge phase? > > If not, then why is it happening like this? I think it's because of caching effects alone, but I am not 100% sure of that. I concede that it might not be enough to make up for the additional I/O on some systems or platforms. The fact remains, however, that the patch was faster on the unsympathetic case I ran on the machine I had available (which has an SSD), and that I really have not managed to find a case that is regressed after some effort. >> I should point out that there is no evidence that any case has been >> regressed, let alone written off entirely or ignored. I looked. I >> probably have not been completely exhaustive, and I'd be willing to >> believe there is something that I've missed, but it's still quite >> possible that there is no downside to any of this. > > If that's so, it's excellent news. As I mentioned up-thread, maybe I shouldn't have brought all the theoretical justifications for killing replacement selection into the discussion so early. Those observations on replacement selection (which are not my own original insights) happen to be what spurred this work. I spent so much time talking about how irrelevant multi-pass merging was that people imagined that that was severely regressed, when it really was not. That just happened to be the way I came at the problem. The numbers speak for themselves here. I just want to be clear about the disadvantages of what I propose, even if it's well worth it overall in most (all?) cases. -- Peter Geoghegan -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers