Speed up match_eclasses_to_foreign_key_col() when there are many ECs.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: e22bfe94e4dfc9abedf17026c3081bca9877163d
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2019-02-21T01:53:08Z
Releases: 11.3
Speed up match_eclasses_to_foreign_key_col() when there are many ECs.

Check ec_relids before bothering to iterate through the EC members.
On a perhaps extreme, but still real-world, query in which
match_eclasses_to_foreign_key_col() accounts for the bulk of the
planner's runtime, this saves nearly 40% of the runtime.  It's a bit
of a stopgap fix, but it's simple enough to be back-patched to 9.6
where this code came in; so let's do that.

David Rowley

Discussion: https://postgr.es/m/6970.1545327857@sss.pgh.pa.us

Files

PathChange+/−
src/backend/optimizer/path/equivclass.c modified +8 −0

Discussion