* find_join_rel * Returns relation entry corresponding to 'relids' (a set of RT indexes), * or NULL if none exists. This is for join relations. */
| 571 | * or NULL if none exists. This is for join relations. |
| 572 | */ |
| 573 | RelOptInfo * |
| 574 | find_join_rel(PlannerInfo *root, Relids relids) |
| 575 | { |
| 576 | /* |
| 577 | * Switch to using hash lookup when list grows "too long". The threshold |
| 578 | * is arbitrary and is known only here. |
| 579 | */ |
| 580 | if (!root->join_rel_hash && list_length(root->join_rel_list) > 32) |
| 581 | build_join_rel_hash(root); |
| 582 | |
| 583 | /* |
| 584 | * Use either hashtable lookup or linear search, as appropriate. |
| 585 | * |
| 586 | * Note: the seemingly redundant hashkey variable is used to avoid taking |
| 587 | * the address of relids; unless the compiler is exceedingly smart, doing |
| 588 | * so would force relids out of a register and thus probably slow down the |
| 589 | * list-search case. |
| 590 | */ |
| 591 | if (root->join_rel_hash) |
| 592 | { |
| 593 | Relids hashkey = relids; |
| 594 | JoinHashEntry *hentry; |
| 595 | |
| 596 | hentry = (JoinHashEntry *) hash_search(root->join_rel_hash, |
| 597 | &hashkey, |
| 598 | HASH_FIND, |
| 599 | NULL); |
| 600 | if (hentry) |
| 601 | return hentry->join_rel; |
| 602 | } |
| 603 | else |
| 604 | { |
| 605 | ListCell *l; |
| 606 | |
| 607 | foreach(l, root->join_rel_list) |
| 608 | { |
| 609 | RelOptInfo *rel = (RelOptInfo *) lfirst(l); |
| 610 | |
| 611 | if (bms_equal(rel->relids, relids)) |
| 612 | return rel; |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | return NULL; |
| 617 | } |
| 618 | |
| 619 | /* |
| 620 | * set_foreign_rel_properties |
no test coverage detected