Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jL54p-0007oR-2v for pgsql-hackers@arkaria.postgresql.org; Sun, 05 Apr 2020 13:12:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jL54n-00043t-R2 for pgsql-hackers@arkaria.postgresql.org; Sun, 05 Apr 2020 13:12:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jL54n-00042h-KH for pgsql-hackers@lists.postgresql.org; Sun, 05 Apr 2020 13:12:37 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jL54l-0008PQ-7e for pgsql-hackers@lists.postgresql.org; Sun, 05 Apr 2020 13:12:36 +0000 Received: by mail-wr1-x443.google.com with SMTP id g3so11816203wrx.2 for ; Sun, 05 Apr 2020 06:12:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ATy4/7Ue0caUnQSJXuUQ6uJNblEIe3Bbm0VEEO+Noaw=; b=sUezqcsniKBkP3W7pWdsUgcTIuVljuunub1yjnevJ0ADKHeQUnCKrJhwkZmX/10mQD CkykmURMOYzVHxnCA9pLuM2VB3lxCZc6MItdqcOxYdknFd2CZCOZyYqP1ubEiZEAygfl MJhMPy1lFSDWIZY6wVNCrV/UoqosJ27Fvb9VZ5/c6YyJ3Aakjr35xUBlFjOs5/0kamjJ 1cbS7n5Fb9/tRLK2mAXHj0U6T97btHvZyrTL8Pu/0lahMJebRBkEawAIIGTIRWmd/1VB Ed2tL2Yz4Rs6VrSjd03e2U4LCyn0phpudP9nrttH1azkC5XUHb2dExug7svMCOpu7IP+ +ubw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ATy4/7Ue0caUnQSJXuUQ6uJNblEIe3Bbm0VEEO+Noaw=; b=r4xOYugUUkaszcZM0JJ9eWzPk2i97QhXQ4OtPNceIt6zIKcp8a54y5XpbYGUUKEVS/ wM5GOdUkU5hAhoTN1E7LVl3v4KAQRU5YmwHaY5kD8FvynE5+e4nkLuFG4LhZBaaZpT4N +bEHdSola5QAWsAyYYuvp52bao05h4zvJLGntZXcY8C5XumnQ3MLj6OQntaf2c1+4W79 CauQBiPkdNGHTOeq0CAt6qvwhOKqOdwc7WPI+R/5riobc6gUcFLsBi3316aTCe1f52nQ fplgL5xrHtTGNlr3xCJoEcFIJ5Xj+tNIjtl0t16SaMQz/d6XXtrJuQVQydv1YykBRL07 55dQ== X-Gm-Message-State: AGi0PuYOQ1A54qopZANOrcL3fOItGAqGKWif/wN+ZqjdqPXTeDlqf0sr XPuYjgqhWttM/4kc3dNvgsYcfA== X-Google-Smtp-Source: APiQypLwsnBs5xKMLLvXYlYNwjJ/2345ge2+LJosbyYX77/CepzlQ4q44bgBaoAYUDOTulZmU8ZwpQ== X-Received: by 2002:a5d:5226:: with SMTP id i6mr7469190wra.257.1586092353089; Sun, 05 Apr 2020 06:12:33 -0700 (PDT) Received: from localhost (ip-86-49-253-141.net.upcbroadband.cz. [86.49.253.141]) by smtp.gmail.com with ESMTPSA id b199sm21982569wme.23.2020.04.05.06.12.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Apr 2020 06:12:31 -0700 (PDT) Date: Sun, 5 Apr 2020 15:12:27 +0200 From: Tomas Vondra To: James Coleman Cc: Tom Lane , Alvaro Herrera , Michael Paquier , Rafia Sabih , Peter Geoghegan , Simon Riggs , Shaun Thomas , Dmitry Dolgov <9erthalion6@gmail.com>, Alexander Korotkov , PostgreSQL Developers , Andreas Karlsson Subject: Re: [PATCH] Incremental sort (was: PoC: Partial sort) Message-ID: <20200405131227.zit6a5w3fv5qq6fh@development> References: <20200401214215.ut6b72e3zlbm33w2@development> <20200402024746.5wlwk6q7eiv5faux@development> <20200403002028.kp3rxncmwvsui6xz@development> <20200405130110.2bdxaz4ed5jx2eae@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200405130110.2bdxaz4ed5jx2eae@development> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, Apr 05, 2020 at 03:01:10PM +0200, Tomas Vondra wrote: >On Thu, Apr 02, 2020 at 09:40:45PM -0400, James Coleman wrote: >>On Thu, Apr 2, 2020 at 8:46 PM James Coleman wrote: >>> >>>On Thu, Apr 2, 2020 at 8:20 PM Tomas Vondra >>> wrote: >>>> ... >>>> 5) Overall, I think the costing is OK. I'm sure we'll find cases that >>>> will need improvements, but that's fine. However, we now have >>>> >>>> - cost_tuplesort (used to be cost_sort) >>>> - cost_full_sort >>>> - cost_incremental_sort >>>> - cost_sort >>>> >>>> I find it a bit confusing that we have cost_sort and cost_full_sort. Why >>>> don't we just keep using the dummy path in label_sort_with_costsize? >>>> That seems to be the only external caller outside costsize.c. Then we >>>> could either make cost_full_sort static or get rid of it entirely. >>> >>>This another area of the patch I haven't really modified. >> >>See attached for a cleanup of this; it removed cost_fullsort so >>label_sort_with_costsize is back to how it was. >> >>I've directly merged this into the patch series; if you'd like to see >>the diff I can send that along. >> > >Thanks. Attached is v54 of the patch, with some minor changes. The main >two changes are in add_partial_path_precheck(), firstly to also consider >startup_cost, as discussed before. The second change (in 0003) is a bit >of an experiment to make add_partial_precheck() cheaper by only calling >compare_pathkeys after checking the costs first (which should be cheaper >than the function call). add_path_precheck already does it in that order >anyway. > Oh, I forgot to mention a change in add_partial_path - I've removed the reference/dependency on enable_incrementalsort. It seemed rather ugly, and the results without it seem fine (I'm benchmarking only the case with incremental sort enabled anyway). I also plan to look at the other optimization we bolted on last week, i.e. checking length of pathkeys. I'll see if that actually makes measurable difference. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services