Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hj308-0000tf-VG for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Jul 2019 14:46:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hj307-0005kC-P8 for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Jul 2019 14:46:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hj307-0005k5-D9 for pgsql-hackers@lists.postgresql.org; Thu, 04 Jul 2019 14:46:19 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hj304-0001uM-Mf for pgsql-hackers@lists.postgresql.org; Thu, 04 Jul 2019 14:46:18 +0000 Received: by mail-wr1-x444.google.com with SMTP id u18so6943784wru.1 for ; Thu, 04 Jul 2019 07:46:16 -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:user-agent; bh=xL5AJYmWrrcG0YRoJvjq0pDPq0DGJ8n6QKnSpxnkK+w=; b=HSonj6yzDX5PWaPWnLpiEdAH9rv8INh1ViTvncDAFFu/B3rI4WoK47EDFburSO7zNQ A9+ofOhp3FDsWcoaobvKNeIIsRN5xwZryq+2etJnHIJL066+QfeEZi314zo3F7e+Yxvc X6pZlC2aOX4AILbBsA0YYKdLVi/gpelPCkJLfXmOegtkoaCAie/KTgGWlaNY9S2mzgoD VMCp+jhhl0GLZtIKrfn+D6F9OOvjKw3ceT+fkoQZcbAsf9g/P+QxBuF+wENRmKZxbp18 vJYPXw/Htjr0wm/Qhz2bDjoOclDar+rox9y6I318ymH5oDFHIKo7sH+ZMDDIDaTYHBE0 6oMQ== 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:user-agent; bh=xL5AJYmWrrcG0YRoJvjq0pDPq0DGJ8n6QKnSpxnkK+w=; b=S//E86Tn5fHiSVTwo0ckizRTa0CdqkvXy7O9ypYj0b3ZqtK63Tdd9YQ/gvEn6Er9Xz flBAZdOb3VX3uDioq7F559CAEeS2c2saqrVkc14+aZfghq7NXM76jfP0FUL5R35munUr lacVnZLmR75T61htzJ6yrKEjXFda6yRRzqJM0nfxQs23Ejh6d41Y0pyDSUDTnzKDjroy rZjv+anu7iXQKEy2yhHE5My0dfBWeO/j1TSYacRyf4vGohuxhd1Ay4NOFcdbReoQQo8K ryP2W45QZc9m6W3x5UYSgsGTFFvJV/mbyWxCGKWV1BAZVV3XAhssWltAnsw7kraOQBgG 8Owg== X-Gm-Message-State: APjAAAVLvCJjWeM5e3osUpduSEFFLYp2Bv0CxYVi/upApaqU4kPgkiz0 uQ6ojJnOhmkWrK3viNzy0wWazw== X-Google-Smtp-Source: APXvYqxx2uAhDLg3NNqSPBy6i8lG5CNC0NKXAy2SeOxf/BjLETPpGGpuSCUg2f7MMSe7QJXI3L48KQ== X-Received: by 2002:a5d:4484:: with SMTP id j4mr25204251wrq.143.1562251574511; Thu, 04 Jul 2019 07:46:14 -0700 (PDT) Received: from localhost (ip-86-49-253-160.net.upcbroadband.cz. [86.49.253.160]) by smtp.gmail.com with ESMTPSA id q16sm392867wra.36.2019.07.04.07.46.13 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 04 Jul 2019 07:46:13 -0700 (PDT) Date: Thu, 4 Jul 2019 16:46:11 +0200 From: Tomas Vondra To: James Coleman Cc: Peter Geoghegan , Simon Riggs , Rafia Sabih , Shaun Thomas , Dmitry Dolgov <9erthalion6@gmail.com>, Alexander Korotkov , Tom Lane , PostgreSQL Developers Subject: Re: [PATCH] Incremental sort (was: PoC: Partial sort) Message-ID: <20190704144611.gsichab2lbxnxaua@development> References: <20190625160235.6ctryjzvw5je7cet@development> <20190625203207.lvmmat7d2ilnr64t@development> <20190625232205.ssecrwplyb7faxbb@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716-1444-295967 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Jul 04, 2019 at 09:29:49AM -0400, James Coleman wrote: >On Tue, Jun 25, 2019 at 7:22 PM Tomas Vondra > wrote: >> >> On Tue, Jun 25, 2019 at 04:53:40PM -0400, James Coleman wrote: >> > >> >Unrelated: if you or someone else you know that's more familiar with >> >the parallel code, I'd be interested in their looking at the patch at >> >some point, because I have a suspicion it might not be operating in >... >> So I've looked into that, and the reason seems fairly simple - when >> generating the Gather Merge paths, we only look at paths that are in >> partial_pathlist. See generate_gather_paths(). >> >> And we only have sequential + index paths in partial_pathlist, not >> incremental sort paths. >> >> IMHO we can do two things: >> >> 1) modify generate_gather_paths to also consider incremental sort for >> each sorted path, similarly to what create_ordered_paths does >> >> 2) modify build_index_paths to also generate an incremental sort path >> for each index path >> >> IMHO (1) is the right choice here, because it automatically does the >> trick for all other types of ordered paths, not just index scans. So, >> something like the attached patch, which gives me plans like this: >... >> But I'm not going to claim those are total fixes, it's the minimum I >> needed to do to make this particular type of plan work. > >Thanks for looking into this! > >I intended to apply this to my most recent version of the patch (just >sent a few minutes ago), but when I apply it I noticed that the >partition_aggregate regression tests have several of these failures: > >ERROR: could not find pathkey item to sort > >I haven't had time to look into the cause yet, so I decided to wait >until the next patch revision. > FWIW I don't claim the patch I shared is complete and/or 100% correct. It was more an illustration of the issue and the smallest patch to make a particular query work. The test failures are a consequence of that. I'll try looking into the failures over the next couple of days, but I can't promise anything. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services