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 1kY9FR-0007z8-5C for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Oct 2020 14:49:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kY9FO-0004QN-Ic for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Oct 2020 14:49:50 +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 <9erthalion6@gmail.com>) id 1kY9FO-0004O6-9C for pgsql-hackers@lists.postgresql.org; Thu, 29 Oct 2020 14:49:50 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1kY9FL-0007o7-Op for pgsql-hackers@lists.postgresql.org; Thu, 29 Oct 2020 14:49:49 +0000 Received: by mail-wr1-x442.google.com with SMTP id i1so3117967wro.1 for ; Thu, 29 Oct 2020 07:49:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=U9grBVzV9gawlHspV4Cadrozum1pR4OXt5du9B8zYNQ=; b=aIvVx5NG3r5bwZStAiT/sT/YhWcoxCVrVd2H/4V/ZKIeqgfJ7Bitn1izAODnqariQ5 gJXYhT4pz2xhdhj2uqsJw/qAapL30V7x710oYa0Drjelz/hRIxjJXFQjmdG4q8ucye3e BdnFEUS+wSEAIs3z4gZABTGFCt3AuClueJQocAx5kVhIwszlefeFfwiJgnxypvit46ln EtYfaEUGpN2KdrWJHoRtQ0Hzoc8j3giUPk52nR70uAnJdqFQFJdeBAr3zXP9tPI6Ncno ALwK4rTFmUjow5AOmOe1PhkekwlkI5mjYZjDeFGoQYwPQMBrZCjJAqNbJJTgJx6R9Rp7 OWMA== 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=U9grBVzV9gawlHspV4Cadrozum1pR4OXt5du9B8zYNQ=; b=l+YuUrgoq/Pq6rFTmoiswrom9KGUlsyGm/O55uFD16iAXWASwhALXPmWVf7yvmMsYI BS2qoz8fzaTXN8QVi3X2gWyGyJ6bI2pjIF6urRW0vdi+KBgqoGwcQ8RGv1jv+08EvHed BXmv1LEBH0bQeSY2iNkB/KJnvlEIhZvm2R+VtH2zQ/L4N/FOOQsEUKVdfOUTcFgndvDw B3nuqhYYUgMlHzMhDTUFMHyDfopIojEc9jlKMy2rqw/BMdCHclCyZzJt6XdhCsCVWL4M 9c6LZPpMQMr04g5Dh4sqcIgIJiKpL/KRUptTywzo7YiyIzRKZDkan19YIFPsInYGYiDj wT+A== X-Gm-Message-State: AOAM530fZYn2I7a+6LOA5sg6dFVxIJYoyHON32O6Mueufq5JcmLiPMjR 172MBG1+1rbCH5E69TcNucU= X-Google-Smtp-Source: ABdhPJxcsY7HYf4J6NnvQTABX1k+sfxmZzR3fi0rj0syV2N8qwBc0dG76lNLMNM3GxLa3SfsZMMrzg== X-Received: by 2002:adf:8bce:: with SMTP id w14mr5949855wra.242.1603982984669; Thu, 29 Oct 2020 07:49:44 -0700 (PDT) Received: from localhost (dslb-178-005-232-008.178.005.pools.vodafone-ip.de. [178.5.232.8]) by smtp.gmail.com with ESMTPSA id c185sm100221wma.44.2020.10.29.07.49.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Oct 2020 07:49:44 -0700 (PDT) Date: Thu, 29 Oct 2020 15:50:25 +0100 From: Dmitry Dolgov <9erthalion6@gmail.com> To: Tomas Vondra Cc: Pavel Borisov , Teodor Sigaev , Gavin Flower , Andres Freund , Michael Paquier , PostgreSQL Developers Subject: Re: POC: GROUP BY optimization Message-ID: <20201029145025.tn3tekboot37nkbf@localhost> References: <20190503215510.bcr5ycszntqg65tw@development> <20190524225725.embuha33qvc5avz3@development> <20200514235220.xewrrwjvatxzn3g6@development> <20201026085721.g6h5xljxvodnmk34@localhost> <20201026104040.6bigvej6f55vjvgp@localhost> <20201027201509.jfv6sfhrmxhdwlvk@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201027201509.jfv6sfhrmxhdwlvk@development> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Tue, Oct 27, 2020 at 09:19:51PM +0100, Tomas Vondra wrote: > On Mon, Oct 26, 2020 at 11:40:40AM +0100, Dmitry Dolgov wrote: > > > On Mon, Oct 26, 2020 at 01:28:59PM +0400, Pavel Borisov wrote: > > > > Thanks for your interest! FYI there is a new thread about this topic [1] > > > > with the next version of the patch and more commentaries (I've created > > > > it for visibility purposes, but probably it also created some confusion, > > > > sorry for that). > > > > > > > > Thanks! > > > > > > I made a very quick look at your updates and noticed that it is intended to > > > be simple and some parts of the code are removed as they have little test > > > coverage. I'd propose vice versa to increase test coverage to enjoy more > > > precise cost calculation and probably partial grouping. > > > > > > Or maybe it's worth to benchmark both patches and then re-decide what we > > > want more to have a more complicated or a simpler version. > > > > > > Good to know that this feature is not stuck anymore and we have more than > > > one proposal. > > > Thanks! > > > > Just to clarify, the patch that I've posted in another thread mentioned > > above is not an alternative proposal, but a development of the same > > patch I had posted in this thread. As mentioned in [1], reduce of > > functionality is an attempt to reduce the scope, and as soon as the base > > functionality looks good enough it will be returned back. > > > > I find it hard to follow two similar threads trying to do the same (or > very similar) things in different ways. Is there any chance to join > forces and produce a single patch series merging the changes? With the > "basic" functionality at the beginning, then patches with the more > complex stuff. That's the usual way, I think. > > As I said in my response on the other thread [1], I think constructing > additional paths with alternative orderings of pathkeys is the right > approach. Otherwise we can't really deal with optimizations above the > place where we consider this optimization. > > That's essentially what I was trying in explain May 16 response [2] > when I actually said this: > > So I don't think there will be a single "interesting" grouping > pathkeys (i.e. root->group_pathkeys), but a collection of pathkeys. > And we'll need to build grouping paths for all of those, and leave > the planner to eventually pick the one giving us the cheapest plan. > > I wouldn't go as far as saying the approach in this patch (i.e. picking > one particular ordering) is doomed, but it's going to be very hard to > make it work reliably. Even if we get the costing *at this node* right, > who knows how it'll affect costing of the nodes above us? > > So if I can suggest something, I'd merge the two patches, adopting the > path-based approach. With the very basic functionality/costing in the > first patch, and the more advanced stuff in additional patches. > > Does that make sense? Yes, and from what I understand it's already what had happened in the newer thread [1]. To avoid any confusion, there are no "two patches" at least from my side, and what I've posted in [1] is the continuation of this work, but with path-based approach adopted and a bit less functionality (essentially I've dropped everything what was not covered with tests in the original patch). In case if I'm missing something and Pavel's proposal is significantly different from the original patch (if I understand correctly, at the moment the latest patch posted here is a rebase and adjusting the old patch to work with the latest changes in master, right?), then indeed they could be merged, but please in the newer thread [1]. [1]: https://www.postgresql.org/message-id/flat/CA%2Bq6zcW_4o2NC0zutLkOJPsFt80megSpX_dVRo6GK9PC-Jx_Ag%40mail.gmail.com