Re: POC: GROUP BY optimization
Dmitry Dolgov <9erthalion6@gmail.com>
From: Dmitry Dolgov <9erthalion6@gmail.com>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Pavel Borisov <pashkin.elfe@gmail.com>, Teodor Sigaev <teodor@sigaev.ru>, Gavin Flower <GavinFlower@archidevsys.co.nz>, Andres Freund <andres@anarazel.de>, Michael Paquier <michael@paquier.xyz>, PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2020-10-29T14:50:25Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Restore preprocess_groupclause()
- 505c008ca37c 17.0 landed
-
Rename PathKeyInfo to GroupByOrdering
- 0c1af2c35c7b 17.0 landed
-
Add invariants check to get_useful_group_keys_orderings()
- 91143c03d4ca 17.0 landed
-
Fix asymmetry in setting EquivalenceClass.ec_sortref
- 199012a3d844 17.0 landed
-
Multiple revisions to the GROUP BY reordering tests
- 874d817baa16 17.0 landed
-
Get rid of pg_class usage in SJE regression tests
- e1b7fde418f2 17.0 landed
-
Rename index "abc" in aggregates.sql
- b91f91870828 17.0 landed
-
Explore alternative orderings of group-by pathkeys during optimization.
- 0452b461bc40 17.0 landed
-
Generalize the common code of adding sort before processing of grouping
- 7ab80ac1caf9 17.0 landed
-
Fix out-dated comment in preprocess_groupclause()
- f6c70b81802a 15.0 landed
- 78a9af1a2764 16.0 landed
-
Force parallelism in partition_aggregate
- 2fe6b2a806f2 16.0 landed
- 01474f56981a 15.0 landed
-
Optimize order of GROUP BY keys
- db0d67db2401 15.0 landed
> 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