postgresql/src/include/nodes
David Rowley 3373c71553 Speed up finding EquivalenceClasses for a given set of rels
Previously in order to determine which ECs a relation had members in, we
had to loop over all ECs stored in PlannerInfo's eq_classes and check if
ec_relids mentioned the relation.  For the most part, this was fine, as
generally, unless queries were fairly complex, the overhead of performing
the lookup would have not been that significant.  However, when queries
contained large numbers of joins and ECs, the overhead to find the set of
classes matching a given set of relations could become a significant
portion of the overall planning effort.

Here we allow a much more efficient method to access the ECs which match a
given relation or set of relations.  A new Bitmapset field in RelOptInfo
now exists to store the indexes into PlannerInfo's eq_classes list which
each relation is mentioned in.  This allows very fast lookups to find all
ECs belonging to a single relation.  When we need to lookup ECs belonging
to a given pair of relations, we can simply bitwise-AND the Bitmapsets from
each relation and use the result to perform the lookup.

We also take the opportunity to write a new implementation of
generate_join_implied_equalities which makes use of the new indexes.
generate_join_implied_equalities_for_ecs must remain as is as it can be
given 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 up
foreign keys matching a join condition which was introduced by 100340e2d.
However, we're speeding up much more than just that here.

Author: David Rowley, Tom Lane
Reviewed-by: Tom Lane, Tomas Vondra
Discussion: https://postgr.es/m/6970.1545327857@sss.pgh.pa.us
2019-07-21 17:30:58 +12:00
..
bitmapset.h Add support for multivariate MCV lists 2019-03-27 18:32:18 +01:00
execnodes.h Fix inconsistencies in the code 2019-07-08 13:15:09 +09:00
extensible.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
lockoptions.h Don't include heapam.h from others headers. 2019-01-14 16:24:41 -08:00
makefuncs.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
memnodes.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
nodeFuncs.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
nodes.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
params.h Refactor ParamListInfo initialization 2019-03-14 13:30:09 +01:00
parsenodes.h Reconcile nodes/*funcs.c with PostgreSQL 12 work. 2019-06-09 14:00:36 -07:00
pathnodes.h Speed up finding EquivalenceClasses for a given set of rels 2019-07-21 17:30:58 +12:00
pg_list.h Avoid using lcons and list_delete_first where it's easy to do so. 2019-07-17 11:15:34 -04:00
plannodes.h Initial pgindent run for v12. 2019-05-22 12:55:34 -04:00
primnodes.h Fix many typos and inconsistencies 2019-07-01 10:00:23 +09:00
print.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
readfuncs.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
replnodes.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
supportnodes.h Allow extensions to generate lossy index conditions. 2019-02-11 21:26:14 -05:00
tidbitmap.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
value.h Update copyright for 2019 2019-01-02 12:44:25 -05:00