Uploaded image for project: 'In-Portal CMS'
  1. In-Portal CMS
  2. INP-788

Automatically remove unused LEFT JOIN from list count database queries

    XMLWordPrintable

    Details

    • Type: Bug Report
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.1.2-B1
    • Fix Version/s: 5.2.0-B1
    • Component/s: Optimization
    • Labels:
      None

      Description

      That's not a rare case, when data from referenced table should be displayed along with data from table being viewed.

      To do that "LEFT JOIN" clause is added a SELECT query being used for data retrieval from database.

      That's not a bad habit actually. But, when table contains 1 million records and has 5 LEFT JOINs on it, then it really slows COUNT database query, used to calculate pagination for that grid.

      I propose that we dynamically remove "LEFT JOIN" parts of database query if JOINed table isn't used anywhere in that database query.

      For example this query doesn't use JOINed table at all, so we can remove it automatically:

      SELECT table1.*
      FROM table1
      LEFT JOIN on table2 ON table1.field = table2.field
      WHERE table1.field = 'test';

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alex Alex
                Reporter:
                alex Alex
                Developer:
                Alex
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: