Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3373c71

Browse files
committed
Speed up finding EquivalenceClasses for a given set of rels
Previously in order to determine which ECs a relation had members in, wehad to loop over all ECs stored in PlannerInfo's eq_classes and check ifec_relids mentioned the relation. For the most part, this was fine, asgenerally, unless queries were fairly complex, the overhead of performingthe lookup would have not been that significant. However, when queriescontained large numbers of joins and ECs, the overhead to find the set ofclasses matching a given set of relations could become a significantportion of the overall planning effort.Here we allow a much more efficient method to access the ECs which match agiven relation or set of relations. A new Bitmapset field in RelOptInfonow exists to store the indexes into PlannerInfo's eq_classes list whicheach relation is mentioned in. This allows very fast lookups to find allECs belonging to a single relation. When we need to lookup ECs belongingto a given pair of relations, we can simply bitwise-AND the Bitmapsets fromeach relation and use the result to perform the lookup.We also take the opportunity to write a new implementation ofgenerate_join_implied_equalities which makes use of the new indexes.generate_join_implied_equalities_for_ecs must remain as is as it can begiven a custom list of ECs, which we can't easily determine the indexes of.This was originally intended to fix the performance penalty of looking upforeign keys matching a join condition which was introduced by100340e.However, we're speeding up much more than just that here.Author: David Rowley, Tom LaneReviewed-by: Tom Lane, Tomas VondraDiscussion:https://postgr.es/m/6970.1545327857@sss.pgh.pa.us
1 parent894af78 commit3373c71

File tree

9 files changed

+306
-82
lines changed

9 files changed

+306
-82
lines changed

‎src/backend/nodes/outfuncs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,6 +2195,7 @@ _outPlannerInfo(StringInfo str, const PlannerInfo *node)
21952195
WRITE_NODE_FIELD(cte_plan_ids);
21962196
WRITE_NODE_FIELD(multiexpr_params);
21972197
WRITE_NODE_FIELD(eq_classes);
2198+
WRITE_BOOL_FIELD(ec_merging_done);
21982199
WRITE_NODE_FIELD(canon_pathkeys);
21992200
WRITE_NODE_FIELD(left_join_clauses);
22002201
WRITE_NODE_FIELD(right_join_clauses);
@@ -2261,6 +2262,7 @@ _outRelOptInfo(StringInfo str, const RelOptInfo *node)
22612262
WRITE_UINT_FIELD(pages);
22622263
WRITE_FLOAT_FIELD(tuples,"%.0f");
22632264
WRITE_FLOAT_FIELD(allvisfrac,"%.6f");
2265+
WRITE_BITMAPSET_FIELD(eclass_indexes);
22642266
WRITE_NODE_FIELD(subroot);
22652267
WRITE_NODE_FIELD(subplan_params);
22662268
WRITE_INT_FIELD(rel_parallel_workers);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp