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

Allocating more space than required for JOIN_TAB array for a query with SJM table

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.1(EOL), 10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5
    • 10.5.0
    • Optimizer
    • None

    Description

      An example

      EXPLAIN SELECT * FROM one_k
      WHERE  a IN (SELECT t10.b 
                                 FROM t10, t11, t12, t13, t14
                                 WHERE t11.a=t10.b+1 AND t12.a=t10.b AND
                                                 t13.a=t10.b AND t14.a=t10.b);
      

      this case uses Semi Join Materializaion and the subquery is added to the table list of select #1.
      The total number of tables for select #1 is 1(one_k)+ 5(inner_tables) + 1(SJM_TABLE). But for the top level we are only considered about 2 and should only have two JOIN_TAB structures.

      In the function JOIN::get_best_combination
      we allocate space for JOIN_TAB array like

        if (!(join_tab= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)*
                                              (top_join_tab_count + aggr_tables))))
      

      In the debugger
      (gdb) p top_join_tab_count
      $8 = 6

      So in this issue we would like to correct the value of top_join_tab_count, to only consider the tables that would be present at the top level. In this case
      the value of top_join_tab_count should be 2.

      Attachments

        Issue Links

          Activity

            varun Varun Gupta (Inactive) created issue -
            varun Varun Gupta (Inactive) made changes -
            Field Original Value New Value
            Description An example

            {code:sql}
            EXPLAIN SELECT * FROM one_k
            WHERE a IN (SELECT t10.b
                                       FROM t10, t11, t12, t13, t14
                                       WHERE t11.a=t10.b+1 AND t12.a=t10.b AND
                                                       t13.a=t10.b AND t14.a=t10.b);
            {code}

            this case uses Semi Join Materializaion and the subquery is added to the table list of select #1.
            The total number of tables for select #1 is 1(one_k)+ 5(inner_tables) + 1(SJM_TABLE). But for the top level we are only considered about 2 and should only have two JOIN_TAB structures.

            In the function JOIN::get_best_combination
            we allocate space for JOIN_TAB array like

            {code:c++}
              if (!(join_tab= (JOIN_TAB*) thd->alloc(sizeof(JOIN_TAB)*
                                                    (top_join_tab_count + aggr_tables))))
            {code}
             
            In the debugger
            (gdb) p top_join_tab_count
            $8 = 6

            So in this issue we would like to correct the value of top_join_tab_count, to only consider the tables that would be present at the top level. In this case
            the value of top_join_tab_count should be 2.
            varun Varun Gupta (Inactive) made changes -
            varun Varun Gupta (Inactive) made changes -
            Summary Allocating more space for JOIN_TAB array for a select with SJM table Allocating more space than required for JOIN_TAB array for a query with SJM table
            varun Varun Gupta (Inactive) made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            varun Varun Gupta (Inactive) made changes -
            Assignee Varun Gupta [ varun ] Sergei Petrunia [ psergey ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            psergei Sergei Petrunia made changes -
            Assignee Sergei Petrunia [ psergey ] Varun Gupta [ varun ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            varun Varun Gupta (Inactive) made changes -
            Fix Version/s 10.5.0 [ 23709 ]
            Fix Version/s 10.5 [ 23123 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 99361 ] MariaDB v4 [ 156689 ]
            ycp Yuchen Pei made changes -

            People

              varun Varun Gupta (Inactive)
              varun Varun Gupta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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