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 1i8mwY-0003QT-Jw for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Sep 2019 14:53:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i8mvZ-0000YU-D6 for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Sep 2019 14:52: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_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8mvY-0000YM-VK for pgsql-hackers@lists.postgresql.org; Fri, 13 Sep 2019 14:52:01 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8mvV-0003p4-N4 for pgsql-hackers@lists.postgresql.org; Fri, 13 Sep 2019 14:52:00 +0000 Received: by mail-wr1-x444.google.com with SMTP id g7so32477754wrx.2 for ; Fri, 13 Sep 2019 07:51:57 -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=liu7EIQ4YisxBhr0w9udtba/t964IS2DLSU+sLoXzl0=; b=bRbuEJ+VU2vsTZNDH0Az6i5zG6lM2QQIHFyi19k7qzZgIsNP53n/KQ3pOiAS2NhlBV U6B6GwjqQMGrn4tHdXORpiju+8YTKTF3WnwVSsEehPYWsKmDUECkxU3res4nz6OdtLiy inhuYJllbhS1uJkGSPvIj0nM17M5rTKcXY3No6+oR7FTSIHvnjqOmiDlV86hiRR32EQV bcMg4IniWXEmCWCSxrWyV35EQ2rv3kW+F3tI68lCReKzKq/cAFeezjLl8WM1B/KTOYSU MNft+YvjZ16TytibfSBp4c8HaiXUSnkHMoaKjpWOTA+gRjjqEXnRx8Rq0/+qSgDfAtgI kMcA== 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=liu7EIQ4YisxBhr0w9udtba/t964IS2DLSU+sLoXzl0=; b=c7uPRm5HGZ+fQRAbbWb1gn9BHGFZj91VHjfjlVGMGSQLNC8/NlDDFINNl+lFiA9lET ONTrQjoXwpwhSbyEAySpmYgBF+L7YOPVz2NI5UfOiBf+GdS4zZqAztsRdD0GM87+tKY8 HqbkkijF4IVF/sDsty6YrzfVdfs5w3nCrQQ0eMoWVLnB40nQYkeXngvwADTqtRCpGnua mkENamrIYJ1v9mIhN86ikEu3nl1rShLKibyNXOVsSPFAD+HaiTkzfnxBAI0Cr6gGETo/ coLMR2jf6GZPOQPXcNgwCVVgAUnQ2H4kWYnLZLhwCpY2Ir3Rw54eiDG692GGCpkExUI/ hJsQ== X-Gm-Message-State: APjAAAWMlrZjIdfP4OQUPY71rC0tu1TcPrsh5esY4uGZJ2WI4d2ejYrc LBxgV9zK/IMTjX6Nse94eQ47Qw== X-Google-Smtp-Source: APXvYqyTvvbs6PUOSwtGGaPjLUYsERiXz2nhDi67ZvxAsew5PJUwI++XYHUK8VyMFz+vMf38weRk7A== X-Received: by 2002:a5d:4985:: with SMTP id r5mr563062wrq.139.1568386316566; Fri, 13 Sep 2019 07:51:56 -0700 (PDT) Received: from localhost (ip-86-49-253-183.net.upcbroadband.cz. [86.49.253.183]) by smtp.gmail.com with ESMTPSA id t6sm4425806wmf.8.2019.09.13.07.51.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2019 07:51:54 -0700 (PDT) Date: Fri, 13 Sep 2019 16:51:53 +0200 From: Tomas Vondra To: Alvaro Herrera Cc: James Coleman , 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: <20190913145153.xthm7dcbt6vgp67x@development> References: <20190730001711.hprrcx3ntk57wuqv@development> <20190912154929.GA2254@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190912154929.GA2254@alvherre.pgsql> User-Agent: NeoMutt/20180716-1444-295967 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Sep 12, 2019 at 12:49:29PM -0300, Alvaro Herrera wrote: >On 2019-Jul-30, Tomas Vondra wrote: > >> On Sun, Jul 21, 2019 at 01:34:22PM +0200, Tomas Vondra wrote: >> > >> > I wonder if we're approaching this wrong. Maybe we should not reverse >> > engineer queries for the various places, but just start with a set of >> > queries that we want to optimize, and then identify which places in the >> > planner need to be modified. > >[...] > >> I've decided to do a couple of experiments, trying to make my mind about >> which modified places matter to diffrent queries. But instead of trying >> to reverse engineer the queries, I've taken a different approach - I've >> compiled a list of queries that I think are sensible and relevant, and >> then planned them with incremental sort enabled in different places. > >[...] > >> The list of queries (synthetic, but hopefully sufficiently realistic) >> and a couple of scripts to collect the plans is in this repository: >> >> https://github.com/tvondra/incremental-sort-tests-2 >> >> There's also a spreadsheet with a summary of results, with a visual >> representation of which GUCs affect which queries. > >OK, so we have that now. I suppose this spreadsheet now tells us which >places are useful and which aren't, at least for the queries that you've >tested. Dowe that mean that we want to get the patch to consider adding >paths only the places that your spreadsheet says are useful? I'm not >sure what the next steps are for this patch. > Yes. I think the spreadsheet call help us with answering two things: 1) places actually affecting the plan (all but three do) 2) redundant places (there are some cases where two GUCs produce the same plan in the end) Of course, this does assume the query set makes sense and is somewhat realistic, but I've tried to construct queries where that is true. We may extend it over time, of course. I think we've agreed to add incremental sort paths different places in separate patches, to make review easier. So this may be a useful way to decide which places to address first. I'd probably do it in this order: - create_ordered_paths - create_ordered_paths (parallel part) - add_paths_to_grouping_rel - ... not sure ... but that's just a proposal. It'd give us most of the benefits, I think, and we could also focus on the rest of the patch. Also, regarding the three GUCs that don't affect any of the queries, we can't really add them as we wouldn't be able to test them. If we manage to construct a query that'd benefit from them, we can revisit this. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services