Re: Eager aggregation, take 3
Richard Guo <guofenglinux@gmail.com>
On Tue, Jan 21, 2025 at 2:57 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: > However, a partial-aggregation path does not generate the same data > as an unaggregated path, no matter how fuzzy you are willing to be > about the concept. So I'm having a very hard time accepting that > it ought to be part of the same RelOptInfo, and thus I don't really > buy that annotating paths with a GroupPathInfo is the way forward. Agreed. I think one point I failed to make myself clear on is that I've never intended to put a partial-aggregation path and an unaggregated path into the same RelOptInfo. One of the basic designs of this patch is that partial-aggregation paths are placed in a separate category of RelOptInfos, which I call "grouped relations" (though I admit that's not the best name). This ensures that we never compare a partial-aggregation path with an unaggregated path during scan/join planning, because I am certain that the two categories of paths are not comparable. Regarding the GroupPathInfo proposal, my intention is to add a valid GroupPathInfo only for the partial-aggregation paths. The goal is to ensure that partial-aggregation paths within this category are compared only if their partial aggregations are at the same location. To be honest, I still doubt that this is necessary. I have two main reasons for this. 1. For a partial-aggregation path, the location where we place the partial aggregation does not impose any restrictions on further planning. This is different from the parameterized path case. If two parameterized paths are equal on very other figure of merit, we will choose the one with fewer required outer rels, as it means fewer join restrictions on upper planning. However, for partial-aggregation paths, we do not have a preference regarding the location of the partial aggregation. For instance, for path "A JOIN PartialAgg(B) JOIN C" and path "PartialAgg(A JOIN B) JOIN C", if one path dominates the other on every figure of merit, it seems to me that there's no point in keeping the less favorable one, although they have their partial aggregations at different join levels. 2. A partial-aggregation path of a rel essentially yields an aggregated form of that rel's row set. The difference between the row sets yielded by paths with different locations of partial aggregation is primarily about the different degrees to which the rows are aggregated. These sets are fundamentally homogeneous. In summary, in my own opinion, I think the partial-aggregation paths of the same "grouped relation" are comparable, regardless of the position of the partial aggregation within the path tree. So I think we should put them into the same RelOptInfo. Of course, I could be very wrong about this. I would greatly appreciate hearing others' thoughts on this. Thanks Richard
Commits
-
Fix eager aggregation for semi/antijoin inner rels
- ffeda04259bb 19 (unreleased) landed
-
Cover additional errors and corner conditions in repack.c
- 2670cc298f42 19 (unreleased) cited
-
Fix volatile function evaluation in eager aggregation
- 3a08a2a8b4fd 19 (unreleased) landed
-
Fix collation handling for grouping keys in eager aggregation
- bd94845e8c90 19 (unreleased) landed
-
Rename apply_at to apply_agg_at for clarity
- 1206df04c200 19 (unreleased) landed
-
Fix comment in eager_aggregate.sql
- 36fd8bde1b77 19 (unreleased) landed
-
Remove unnecessary include of "utils/fmgroids.h"
- f997d777adf7 19 (unreleased) landed
-
Implement Eager Aggregation
- 8e11859102f9 19 (unreleased) landed
-
Allow negative aggtransspace to indicate unbounded state size
- 185e30426334 19 (unreleased) landed
-
Add macros for looping through a List without a ListCell.
- 14dd0f27d7cd 17.0 cited
-
Account for the effect of lossy pages when costing bitmap scans.
- 5edc63bda68a 11.0 cited
-
Fix a thinko in join_is_legal: when we decide we can implement a semijoin
- a43b190e3c71 9.0.0 cited