PostgreSQLはどこでsqlクエリの62を処理します

3730 ワード

はい
RelOptInfo *make_join_rel(PlannerInfo*root,RelOptInfo*rel 1,RelOptInfo*rel 2)関数を検討する:
inner joinの時に起こったことを見てみましょう.
RelOptInfo *

make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)

{

   ...

   SpecialJoinInfo *sjinfo;

   ...

   /* Check validity and determine join type. */

   if (!join_is_legal(root, rel1, rel2, joinrelids,

                      &sjinfo, &reversed))

   ...

   /*

    * If it's a plain inner join, then we won't have found anything in

    * join_info_list.    Make up a SpecialJoinInfo so that selectivity

    * estimation functions will know what's being joined.

    */

   if (sjinfo == NULL)

   {

        sjinfo = &sjinfo_data;

        sjinfo->type = T_SpecialJoinInfo;

        sjinfo->min_lefthand = rel1->relids;

        sjinfo->min_righthand = rel2->relids;

        sjinfo->syn_lefthand = rel1->relids;

        sjinfo->syn_righthand = rel2->relids;

        sjinfo->jointype = JOIN_INNER;

        /* we don't bother trying to make the remaining fields valid */

        sjinfo->lhs_strict = false;

        sjinfo->delay_upper_joins = false;

        sjinfo->join_quals = NIL;

   }

   ...

   switch (sjinfo->jointype)

   {

        case JOIN_INNER:



            fprintf(stderr,"JOIN_INNER 
"); if (is_dummy_rel(rel1) || is_dummy_rel(rel2) || restriction_is_constant_false(restrictlist, false)) { mark_dummy_rel(joinrel); break; } add_paths_to_joinrel(root, joinrel, rel1, rel2, JOIN_INNER, sjinfo, restrictlist); add_paths_to_joinrel(root, joinrel, rel2, rel1, JOIN_INNER, sjinfo, restrictlist); break; ... } ... }