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 1hDsYr-0002S9-Qx for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Apr 2019 15:21: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 1hDsYq-0007Ff-Bd for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Apr 2019 15:21:20 +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 1hDsYq-0007FY-2i for pgsql-hackers@lists.postgresql.org; Tue, 09 Apr 2019 15:21:20 +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 1hDsYi-0006Fw-SP for pgsql-hackers@lists.postgresql.org; Tue, 09 Apr 2019 15:21:19 +0000 Received: by mail-wr1-x444.google.com with SMTP id y13so21449933wrd.3 for ; Tue, 09 Apr 2019 08:21:12 -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=kFlE7UJu3ZeatuCeBp74FLO5j+rkeS4v1iuF7up66V0=; b=zT9XlwyLh/UKMpUeh1w4evyY6ENwWBOWXmPcAxoFqB1BGhLwaqH6CyAl7qPzdOPFeS WNhqdz8uAMb9guJx24PDe5jo8RE2zZ5l6v9Hc2iESoAEkNUof4ut90w4KBx2zbsryFB8 pmXkEeYGaylAQ0dV64Ig9qQWjwl8jNL6yYn59QqScyBh4DlDXZZHVm3hRpOLzBfga1LG nJ+SXGia62mtfMD7hAxgyUR/eeYjIJduxZ+d2Bn2uHBy5WoM1dpIonpMrVjhCKXZzrMM VCe0kvjnRbGTx2KKkxGW1XcFsQcdHfB6BUtwKqUqJlWtDD0nocSyFPq8Dx2mP8PpBSnj zsxQ== 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=kFlE7UJu3ZeatuCeBp74FLO5j+rkeS4v1iuF7up66V0=; b=P2ADiTqOOFdzj926VevJMSNRx0RncftXBtKDxL6srcN2g2t9tkL8sx+ArHEjtCMlPF z/XD59Nco1jA7M1fFuckTSVeg5yP+WSxKPJzu/v8QM3rI5bY0xuzO1NXNWhO6sLJjhpY usry5u91qso8UYmgg8cV33cidNrPE06OzcZjTu5U25gRrAGVHydl3U0haHZASYQM99ou FMmdxKr8WiGhtn8HFxgOYwoAzdrtbw7jGN8GgACniM7HTjwuoc/Ojbe4+Lo8eZn9kGG5 qaJyccnJ0fLPgGVEye/SiBwV1yjnM7+gV3bbPtEhiQvYewVQsheNCQIiozCjnC50kila 4qzQ== X-Gm-Message-State: APjAAAUSJY0Xm6CtjhiD1X/dlN0sg/JiotbCyw6Laey339Ien+UcS04K 0uODgNfkgHv7DadpAbLv9poxQA== X-Google-Smtp-Source: APXvYqwVzytAXsmvWrRq2aF0BSpGZcMGLgH/qhp2yA+pfZiAWa3Cwxkk8rv8iQEA2YovSxUNNnxdYw== X-Received: by 2002:adf:fc0b:: with SMTP id i11mr5393286wrr.145.1554823271378; Tue, 09 Apr 2019 08:21:11 -0700 (PDT) Received: from localhost (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id j11sm44263685wrw.85.2019.04.09.08.21.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 09 Apr 2019 08:21:04 -0700 (PDT) Date: Tue, 9 Apr 2019 17:21:00 +0200 From: Tomas Vondra To: Dmitry Dolgov <9erthalion6@gmail.com> Cc: Teodor Sigaev , Gavin Flower , Andres Freund , Michael Paquier , PostgreSQL Developers Subject: Re: POC: GROUP BY optimization Message-ID: <20190409152100.5q25whnxs27zws5m@development> References: <623f5e50-eeb2-1279-d30b-dc43611fb063@2ndquadrant.com> <1913e082-0d8d-5eb8-c8ca-053af828076a@2ndquadrant.com> <3bbdd1ee-544d-a549-b0c2-30485d9f6a16@sigaev.ru> <83b0d707-405d-c2be-0d98-01267e68d671@2ndquadrant.com> <0b3ee377-2f67-f58d-6177-bc2ed4626499@archidevsys.co.nz> <20181002021626.GF11712@paquier.xyz> <20190131112407.zpbysdvghjyh4z47@alap3.anarazel.de> 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-dirty List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Apr 04, 2019 at 05:11:09PM +0200, Dmitry Dolgov wrote: >> On Thu, Jan 31, 2019 at 12:24 PM Andres Freund wrote: >> >> As nothing has happened since, I'm marking this as returned with >> feedback. > >This patch was on my radar for some time in the past and we've seen use cases >where it could be pretty useful (probably even without the incremental sort >patch). I would like to make some progress here and see if it's possible to >continue it's development. I've attached the rebased version with a small >changes, e.g. I've created a separate patch with group by reordering tests to >make it easy to see what changes were introduced, and after some experiments >removed part that seems to duplicate "group by" reordering to follow "order >by". Also looks like it's possible to make these patches independent by having >a base patch with the isolated group_keys_reorder_by_pathkeys (they're >connected via n_preordered), but I haven't done this yet. > >I went through the thread to summarize the objections, that were mentioned so >far. Most of them are related to the third patch in the series, where >reordering based on "ndistincs" is implemented, and are about cost_sort (all >the possible problems that could happen without proper cost estimation due to >non uniform distribution, different comparison costs and so on) and figuring >out how to limit number of possible combinations of pathkeys to compare. I >haven't looked at the proposed backtracking approach, but taking into account >that suggested patch for cost_sort [1] is RWF, I wonder what would be the best >strategy to proceed? > >[1]: https://commitfest.postgresql.org/21/1706/ Dunno. It seems the progres on the sort-related patches was rather limited in the PG12 cycle in general :-( There's the Incremental Sort patch, GROUP BY optimization and then the cost_sort patch. Not sure about the best strategy, though. One obvious option is to rely on cost_sort patch to do all the improvements needed for the other patches, but that assumes that patch moves reasonably fast. So I personally would suggest to treat those patches as independent until the very last moment, develop the costing improvements needed by each of them, and then decide which of them are committable / in what order. At the end of PG11 cycle I've offered my help with testing / reviewing those patches, if there is progress. That still holds, if there are new patch versions I'll look at them. cheers -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services