Re: POC: GROUP BY optimization
Dmitry Dolgov <9erthalion6@gmail.com>
From: Dmitry Dolgov <9erthalion6@gmail.com>
To: Teodor Sigaev <teodor@sigaev.ru>,
Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Gavin Flower <GavinFlower@archidevsys.co.nz>,
Andres Freund <andres@anarazel.de>, Michael Paquier <michael@paquier.xyz>, PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2019-04-04T15:11:09Z
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
Attachments
- v11-0001-Add-tests-for-group-by-optimization.patch (application/octet-stream) patch v11-0001
- v11-0002-Reorder-to-match-ORDER-BY-or-index.patch (application/octet-stream) patch v11-0002
- v11-0003-Reorder-by-values-distribution.patch (application/octet-stream) patch v11-0003
> On Thu, Jan 31, 2019 at 12:24 PM Andres Freund <andres@anarazel.de> 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/