Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-39659

FULL JOIN algorithm for single table(?) and join buffer (BNL[-H])

    XMLWordPrintable

Details

    • Task
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • None

    Description

      Suppose we're running

        t1 full outer join t2 on on_expr
      

      and we use join buffer.

      The first step is to read rows from t1 and put them into join buffer:

        join_buffer 
          t1.recordX, match_flag=false
          t1.recordY, match_flag=false
          t1.recordZ, match_flag=false
      

      Suppose the join buffer is large enough and all records from t1 fit there.

      Then we do joining. I am providing existing LEFT JOIN algorithm, comments show how we can add FULL JOIN easily:

        for each record R2 in t2  {
          
          for each record R1 from join buffer {
            if (on_expr(R1, R2)) 
              emit(R1.t1_record, R2);
          }
       
          // If the above loop didn't produce anything, we know 
          // that R2 didn't have a match.
          // So, we can do:
          //  emit(t1.null_complemented_record, R2);
        }
       
        for each record R1 in join_buffer {
          if (R1.match_flag == false)
            emit(R1.t1_record,  t2.null_complemented_record);
        }
      

      Note that this doesn't require a temporary table, or any extra space in the join buffer.

      The only condition is that all the matching rows from the first table fit into the join buffer.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              psergei Sergei Petrunia
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.