forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit3373c71
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.us1 parent894af78 commit3373c71
File tree
9 files changed
+306
-82
lines changed- src
- backend
- nodes
- optimizer
- path
- plan
- prep
- util
- include/nodes
9 files changed
+306
-82
lines changedLines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2195 | 2195 |
| |
2196 | 2196 |
| |
2197 | 2197 |
| |
| 2198 | + | |
2198 | 2199 |
| |
2199 | 2200 |
| |
2200 | 2201 |
| |
| |||
2261 | 2262 |
| |
2262 | 2263 |
| |
2263 | 2264 |
| |
| 2265 | + | |
2264 | 2266 |
| |
2265 | 2267 |
| |
2266 | 2268 |
| |
|
0 commit comments
Comments
(0)