Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fy0zD-0004d5-KV for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Sep 2018 20:34:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fy0zC-0001jX-3A for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Sep 2018 20:34:42 +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.89) (envelope-from ) id 1fy0zB-0001jQ-SF for pgsql-hackers@lists.postgresql.org; Thu, 06 Sep 2018 20:34:41 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fy0z8-00050m-IF for pgsql-hackers@lists.postgresql.org; Thu, 06 Sep 2018 20:34:41 +0000 Received: by mail-wm0-x241.google.com with SMTP id f21-v6so12636296wmc.5 for ; Thu, 06 Sep 2018 13:34:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=baWJ+789hQIfyHkOtje6zwJQQqndT5o8W3kK/QCawZQ=; b=jMe/p19mysBUDLnBQhoTf/R91nxLV4hUcWVJG+wBXgHueo+NaMrRLWZQ6/Ks1fGGHe JeLSOarxpl6TloqagToHksfLt+StZ1cxmYV58R1aYKoadIqYruKTlAxkAYlwWkETZxS8 4Ex5Ihx3ZKdhzG6HogmXxLrOnU+lXoJlbWhigMT+cbsVpq9xh5buMYpWXm5iaCb0Nx12 M/4EI7n2r3/a1MupSXzkBmErbAIpFHAsc9BecEs/A+OXvWmsRHSSrQIXvOQ+AFyY0mMo fKjDF8im//5PhyqX22QlD1HZmrC1Xb1J5uBGohSOIoKlU3q63iC5YAfrsKVo0Z1akiUH PSAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=baWJ+789hQIfyHkOtje6zwJQQqndT5o8W3kK/QCawZQ=; b=r3yPVgX6gVp2WEA3nOp4zNhrj2TRm22+mK8JNLrIOfLm8WSggABxXQ2JF5GBmCygsp /7cLfVzr7NFIyEtwA7VNEOQnhCULZuX2+nem2BMPZaQ2j1rCmHTMGcPAMst3oJEcqc1+ dLb8W2R4qNi15A/UNyDJmkDAP5Y1ax5RiWv1LQndYcymjXbB6AsfSSE3EXfei/DbR7an 2Z9Knp2Tx+57DUjgb9+PV3NGZx/RQIAvw155F+pldq0D5PvzfkSniw7bHezux73hV/f+ SsJO68lAAMDjPwfUMpmVlXXsBrniKlJ8NEOdJV0Fd83eEfq9YYERlRtgE6FMkE4NGpwn vYjA== X-Gm-Message-State: APzg51BpAss84pQdXv0dE1v517OjAqZ2+dFSmGn0N5bsd1ejzbKdHKLd aWXTroAbgrAY8vpNr+sqbVc13g== X-Google-Smtp-Source: ANB0VdaNiTaWuvbKzAlbqt6gROxY1oqBaMi7mJMmmX8Jx7ren1OyQKN2TZzLqjHWATFMbupq/EGNWw== X-Received: by 2002:a1c:a60e:: with SMTP id p14-v6mr3508679wme.64.1536266077584; Thu, 06 Sep 2018 13:34:37 -0700 (PDT) Received: from [10.137.2.19] (ip-86-49-246-121.net.upcbroadband.cz. [86.49.246.121]) by smtp.gmail.com with ESMTPSA id g2-v6sm4542471wme.20.2018.09.06.13.34.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 13:34:36 -0700 (PDT) Subject: Re: [PATCH] Incremental sort (was: PoC: Partial sort) To: James Coleman , Tom Lane Cc: pgsql-hackers@lists.postgresql.org, Alexander Korotkov References: <153625271389.4078.18405235923135713189.pgcf@coridan.postgresql.org> <16617.1536255587@sss.pgh.pa.us> From: Tomas Vondra Message-ID: Date: Thu, 6 Sep 2018 22:34:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 09/06/2018 08:04 PM, James Coleman wrote: > I disagree because it's not ideal to basically have to append pk to > every index in the system just to get the ability to tie-break when > there's actually very low likelihood of ties anyway. > > A similar use case is trying to batch through a result set, in which > case you need a stable sort as well. > > The benefit is retaining the generality of indexes (and saving space in > them etc.) while still allowing using them for more specific sorts. Any > time you paginate or batch this way you benefit from this, which in many > applications applies to a very high percentage of indexes. > I 100% with this. I see incremental sort as a way to run queries with fewer indexes that are less query-specific, while still benefiting from them. Which means lower overhead when writing data, lower disk space usage, and so on. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services