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

Perfromance Degradation of Joins on VIEWs after v10.4.22

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.4.31, 10.11.5, 10.4(EOL), 10.5, 10.6, 10.11, 11.0(EOL), 11.1(EOL), 11.2(EOL), 11.3(EOL), 11.4
    • 10.5, 10.6, 10.11, 11.4
    • None
    • RHEL 8

    Description

      We tried upgrading current 10.4.22 to the next version and discovered that an existing VIEW used in JOIN takes more than 45mins to return the results. But in 10.4.22 we're getting the results within 8 seconds for 25000 records. We discovered the same behavior with recent 10.4.31 and 10.11.5 too.

      Below is the VIEW we're using:

      CREATE DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `vRecord` AS 
      SELECT
        H1.`id` AS `historyId`, H1.`uId` AS `uId`, H1.`jobTitleId` AS `jobTitleId`, H1.`joinedDate` AS `joinedDate`, 
        H1.`eDate` AS `eDate`, H1.`eventId` AS `eventId`, HE.`name` AS `eventName`
      FROM (
        (`History` H1
          LEFT JOIN `HistoryEvent` HE ON (HE.`id` = H1.`eventId`)
        ) JOIN (
          SELECT SH1.`uId` AS `uId`, MAX(SH1.`id`) AS `id`
          FROM (
            (
              SELECT `id`, `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
              FROM `History`
            ) SH1
            JOIN (
              SELECT TMP.`uId` AS `uId`, MAX(TMP.`eDate`) AS `eDate`
              FROM (
                SELECT `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
                FROM `History`
              ) TMP
              WHERE TMP.`eDate` <= curdate()
              GROUP BY TMP.`uId`
            ) SH2 ON (SH1.`uId` = SH2.`uId` and SH1.`eDate` = SH2.`eDate`)
          )
          GROUP BY SH1.`uId`
        ) H2 ON (H1.`uId` = H2.`uId` and H1.`id` = H2.`id`)
      );
      

      This has become a blocker for our application.

      Attachments

        Issue Links

          Activity

            amilwaduwawara Amil Waduwawara created issue -
            amilwaduwawara Amil Waduwawara made changes -
            Field Original Value New Value
            Description We tried upgrading current 10.4.22 to the next version and discovered that an existing VIEW used in JOIN takes more than 45mins to return the results. But in 10.4.22 we're getting the results within 8 seconds for 25000 records. We discovered the same behavior with recent 10.4.31 and 10.11.5 too.

            Below is the VIEW we're using:
            {{CREATE DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `vRecord` AS
            SELECT * FROM (
            (`History` H1
            LEFT JOIN `HistoryEvent` HE ON (HE.`id` = H1.`eventId`)
            ) JOIN (
            SELECT SH1.`uId` AS `uId`, MAX(SH1.`id`) AS `id`
            FROM (
            (
            SELECT `id`, `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
            FROM `History`
            ) SH1
            JOIN (
            SELECT TMP.`uId` AS `uId`, MAX(TMP.`eDate`) AS `eDate`
            FROM (
            SELECT `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
            FROM `History`
            ) TMP
            WHERE TMP.`eDate` <= curdate()
            GROUP BY TMP.`uId`
            ) SH2 ON (SH1.`uId` = SH2.`uId` and SH1.`eDate` = SH2.`eDate`)
            )
            GROUP BY SH1.`uId`
            ) H2 ON (H1.`uId` = H2.`uId` and H1.`id` = H2.`id`)
            );}}

            This has become a blocker for our application.
            We tried upgrading current 10.4.22 to the next version and discovered that an existing VIEW used in JOIN takes more than 45mins to return the results. But in 10.4.22 we're getting the results within 8 seconds for 25000 records. We discovered the same behavior with recent 10.4.31 and 10.11.5 too.

            Below is the VIEW we're using:
            {{
            CREATE DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `vRecord` AS
            SELECT * FROM (
            (`History` H1
            LEFT JOIN `HistoryEvent` HE ON (HE.`id` = H1.`eventId`)
            ) JOIN (
            SELECT SH1.`uId` AS `uId`, MAX(SH1.`id`) AS `id`
            FROM (
            (
            SELECT `id`, `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
            FROM `History`
            ) SH1
            JOIN (
            SELECT TMP.`uId` AS `uId`, MAX(TMP.`eDate`) AS `eDate`
            FROM (
            SELECT `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
            FROM `History`
            ) TMP
            WHERE TMP.`eDate` <= curdate()
            GROUP BY TMP.`uId`
            ) SH2 ON (SH1.`uId` = SH2.`uId` and SH1.`eDate` = SH2.`eDate`)
            )
            GROUP BY SH1.`uId`
            ) H2 ON (H1.`uId` = H2.`uId` and H1.`id` = H2.`id`)
            );
            }}

            This has become a blocker for our application.
            amilwaduwawara Amil Waduwawara made changes -
            Description We tried upgrading current 10.4.22 to the next version and discovered that an existing VIEW used in JOIN takes more than 45mins to return the results. But in 10.4.22 we're getting the results within 8 seconds for 25000 records. We discovered the same behavior with recent 10.4.31 and 10.11.5 too.

            Below is the VIEW we're using:
            {{
            CREATE DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `vRecord` AS
            SELECT * FROM (
            (`History` H1
            LEFT JOIN `HistoryEvent` HE ON (HE.`id` = H1.`eventId`)
            ) JOIN (
            SELECT SH1.`uId` AS `uId`, MAX(SH1.`id`) AS `id`
            FROM (
            (
            SELECT `id`, `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
            FROM `History`
            ) SH1
            JOIN (
            SELECT TMP.`uId` AS `uId`, MAX(TMP.`eDate`) AS `eDate`
            FROM (
            SELECT `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
            FROM `History`
            ) TMP
            WHERE TMP.`eDate` <= curdate()
            GROUP BY TMP.`uId`
            ) SH2 ON (SH1.`uId` = SH2.`uId` and SH1.`eDate` = SH2.`eDate`)
            )
            GROUP BY SH1.`uId`
            ) H2 ON (H1.`uId` = H2.`uId` and H1.`id` = H2.`id`)
            );
            }}

            This has become a blocker for our application.
            We tried upgrading current 10.4.22 to the next version and discovered that an existing VIEW used in JOIN takes more than 45mins to return the results. But in 10.4.22 we're getting the results within 8 seconds for 25000 records. We discovered the same behavior with recent 10.4.31 and 10.11.5 too.

            Below is the VIEW we're using:

            CREATE DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `vRecord` AS
            SELECT * FROM (
            (`History` H1
            LEFT JOIN `HistoryEvent` HE ON (HE.`id` = H1.`eventId`)
            ) JOIN (
            SELECT SH1.`uId` AS `uId`, MAX(SH1.`id`) AS `id`
            FROM (
            (
            SELECT `id`, `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
            FROM `History`
            ) SH1
            JOIN (
            SELECT TMP.`uId` AS `uId`, MAX(TMP.`eDate`) AS `eDate`
            FROM (
            SELECT `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
            FROM `History`
            ) TMP
            WHERE TMP.`eDate` <= curdate()
            GROUP BY TMP.`uId`
            ) SH2 ON (SH1.`uId` = SH2.`uId` and SH1.`eDate` = SH2.`eDate`)
            )
            GROUP BY SH1.`uId`
            ) H2 ON (H1.`uId` = H2.`uId` and H1.`id` = H2.`id`)
            );



            This has become a blocker for our application.
            amilwaduwawara Amil Waduwawara made changes -
            Description We tried upgrading current 10.4.22 to the next version and discovered that an existing VIEW used in JOIN takes more than 45mins to return the results. But in 10.4.22 we're getting the results within 8 seconds for 25000 records. We discovered the same behavior with recent 10.4.31 and 10.11.5 too.

            Below is the VIEW we're using:

            CREATE DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `vRecord` AS
            SELECT * FROM (
            (`History` H1
            LEFT JOIN `HistoryEvent` HE ON (HE.`id` = H1.`eventId`)
            ) JOIN (
            SELECT SH1.`uId` AS `uId`, MAX(SH1.`id`) AS `id`
            FROM (
            (
            SELECT `id`, `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
            FROM `History`
            ) SH1
            JOIN (
            SELECT TMP.`uId` AS `uId`, MAX(TMP.`eDate`) AS `eDate`
            FROM (
            SELECT `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
            FROM `History`
            ) TMP
            WHERE TMP.`eDate` <= curdate()
            GROUP BY TMP.`uId`
            ) SH2 ON (SH1.`uId` = SH2.`uId` and SH1.`eDate` = SH2.`eDate`)
            )
            GROUP BY SH1.`uId`
            ) H2 ON (H1.`uId` = H2.`uId` and H1.`id` = H2.`id`)
            );



            This has become a blocker for our application.
            We tried upgrading current 10.4.22 to the next version and discovered that an existing VIEW used in JOIN takes more than 45mins to return the results. But in 10.4.22 we're getting the results within 8 seconds for 25000 records. We discovered the same behavior with recent 10.4.31 and 10.11.5 too.

            Below is the VIEW we're using:
            {code:sql}
            CREATE DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `vRecord` AS
            SELECT * FROM (
            (`History` H1
            LEFT JOIN `HistoryEvent` HE ON (HE.`id` = H1.`eventId`)
            ) JOIN (
            SELECT SH1.`uId` AS `uId`, MAX(SH1.`id`) AS `id`
            FROM (
            (
            SELECT `id`, `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
            FROM `History`
            ) SH1
            JOIN (
            SELECT TMP.`uId` AS `uId`, MAX(TMP.`eDate`) AS `eDate`
            FROM (
            SELECT `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
            FROM `History`
            ) TMP
            WHERE TMP.`eDate` <= curdate()
            GROUP BY TMP.`uId`
            ) SH2 ON (SH1.`uId` = SH2.`uId` and SH1.`eDate` = SH2.`eDate`)
            )
            GROUP BY SH1.`uId`
            ) H2 ON (H1.`uId` = H2.`uId` and H1.`id` = H2.`id`)
            );
            {code}


            This has become a blocker for our application.
            amilwaduwawara Amil Waduwawara made changes -
            Description We tried upgrading current 10.4.22 to the next version and discovered that an existing VIEW used in JOIN takes more than 45mins to return the results. But in 10.4.22 we're getting the results within 8 seconds for 25000 records. We discovered the same behavior with recent 10.4.31 and 10.11.5 too.

            Below is the VIEW we're using:
            {code:sql}
            CREATE DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `vRecord` AS
            SELECT * FROM (
            (`History` H1
            LEFT JOIN `HistoryEvent` HE ON (HE.`id` = H1.`eventId`)
            ) JOIN (
            SELECT SH1.`uId` AS `uId`, MAX(SH1.`id`) AS `id`
            FROM (
            (
            SELECT `id`, `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
            FROM `History`
            ) SH1
            JOIN (
            SELECT TMP.`uId` AS `uId`, MAX(TMP.`eDate`) AS `eDate`
            FROM (
            SELECT `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
            FROM `History`
            ) TMP
            WHERE TMP.`eDate` <= curdate()
            GROUP BY TMP.`uId`
            ) SH2 ON (SH1.`uId` = SH2.`uId` and SH1.`eDate` = SH2.`eDate`)
            )
            GROUP BY SH1.`uId`
            ) H2 ON (H1.`uId` = H2.`uId` and H1.`id` = H2.`id`)
            );
            {code}


            This has become a blocker for our application.
            We tried upgrading current 10.4.22 to the next version and discovered that an existing VIEW used in JOIN takes more than 45mins to return the results. But in 10.4.22 we're getting the results within 8 seconds for 25000 records. We discovered the same behavior with recent 10.4.31 and 10.11.5 too.

            Below is the VIEW we're using:
            {code:sql}
            CREATE DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `vRecord` AS
            SELECT * FROM (
              (`History` H1
                LEFT JOIN `HistoryEvent` HE ON (HE.`id` = H1.`eventId`)
              ) JOIN (
                SELECT SH1.`uId` AS `uId`, MAX(SH1.`id`) AS `id`
                FROM (
                  (
                    SELECT `id`, `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
                    FROM `History`
                  ) SH1
                  JOIN (
                    SELECT TMP.`uId` AS `uId`, MAX(TMP.`eDate`) AS `eDate`
                    FROM (
                      SELECT `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
                      FROM `History`
                    ) TMP
                    WHERE TMP.`eDate` <= curdate()
                    GROUP BY TMP.`uId`
                  ) SH2 ON (SH1.`uId` = SH2.`uId` and SH1.`eDate` = SH2.`eDate`)
                )
                GROUP BY SH1.`uId`
              ) H2 ON (H1.`uId` = H2.`uId` and H1.`id` = H2.`id`)
            );
            {code}


            This has become a blocker for our application.
            amilwaduwawara Amil Waduwawara made changes -
            Summary Perfromance Degradation of Joins on VIEWs after some changes Perfromance Degradation of Joins on VIEWs after v10.4.22
            alice Alice Sherepa made changes -
            Status Open [ 1 ] Needs Feedback [ 10501 ]
            amilwaduwawara Amil Waduwawara made changes -
            Attachment 2023115--feedback--01.txt [ 72488 ]
            amilwaduwawara Amil Waduwawara made changes -
            Attachment 2023115--feedback--01.txt [ 72488 ]
            amilwaduwawara Amil Waduwawara made changes -
            Attachment 20231115--feedback--01.txt [ 72489 ]
            amilwaduwawara Amil Waduwawara made changes -
            Description We tried upgrading current 10.4.22 to the next version and discovered that an existing VIEW used in JOIN takes more than 45mins to return the results. But in 10.4.22 we're getting the results within 8 seconds for 25000 records. We discovered the same behavior with recent 10.4.31 and 10.11.5 too.

            Below is the VIEW we're using:
            {code:sql}
            CREATE DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `vRecord` AS
            SELECT * FROM (
              (`History` H1
                LEFT JOIN `HistoryEvent` HE ON (HE.`id` = H1.`eventId`)
              ) JOIN (
                SELECT SH1.`uId` AS `uId`, MAX(SH1.`id`) AS `id`
                FROM (
                  (
                    SELECT `id`, `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
                    FROM `History`
                  ) SH1
                  JOIN (
                    SELECT TMP.`uId` AS `uId`, MAX(TMP.`eDate`) AS `eDate`
                    FROM (
                      SELECT `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
                      FROM `History`
                    ) TMP
                    WHERE TMP.`eDate` <= curdate()
                    GROUP BY TMP.`uId`
                  ) SH2 ON (SH1.`uId` = SH2.`uId` and SH1.`eDate` = SH2.`eDate`)
                )
                GROUP BY SH1.`uId`
              ) H2 ON (H1.`uId` = H2.`uId` and H1.`id` = H2.`id`)
            );
            {code}


            This has become a blocker for our application.
            We tried upgrading current 10.4.22 to the next version and discovered that an existing VIEW used in JOIN takes more than 45mins to return the results. But in 10.4.22 we're getting the results within 8 seconds for 25000 records. We discovered the same behavior with recent 10.4.31 and 10.11.5 too.

            Below is the VIEW we're using:
            {code:sql}
            CREATE DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `vRecord` AS
            SELECT
              H1.`id` AS `historyId`, H1.`uId` AS `uId`, H1.`jobTitleId` AS `jobTitleId`, H1.`joinedDate` AS `joinedDate`,
              H1.`eDate` AS `eDate`, H1.`eventId` AS `eventId`, HE.`name` AS `eventName`
            FROM (
              (`History` H1
                LEFT JOIN `HistoryEvent` HE ON (HE.`id` = H1.`eventId`)
              ) JOIN (
                SELECT SH1.`uId` AS `uId`, MAX(SH1.`id`) AS `id`
                FROM (
                  (
                    SELECT `id`, `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
                    FROM `History`
                  ) SH1
                  JOIN (
                    SELECT TMP.`uId` AS `uId`, MAX(TMP.`eDate`) AS `eDate`
                    FROM (
                      SELECT `uId`, IFNULL(`eDate`, '1970-01-01') AS `eDate`
                      FROM `History`
                    ) TMP
                    WHERE TMP.`eDate` <= curdate()
                    GROUP BY TMP.`uId`
                  ) SH2 ON (SH1.`uId` = SH2.`uId` and SH1.`eDate` = SH2.`eDate`)
                )
                GROUP BY SH1.`uId`
              ) H2 ON (H1.`uId` = H2.`uId` and H1.`id` = H2.`id`)
            );
            {code}


            This has become a blocker for our application.
            alice Alice Sherepa made changes -
            Status Needs Feedback [ 10501 ] Open [ 1 ]
            alice Alice Sherepa made changes -
            Status Open [ 1 ] Needs Feedback [ 10501 ]
            alice Alice Sherepa made changes -
            Status Needs Feedback [ 10501 ] Open [ 1 ]
            alice Alice Sherepa made changes -
            Fix Version/s 10.4 [ 22408 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.11 [ 27614 ]
            Fix Version/s 11.0 [ 28320 ]
            Fix Version/s 11.1 [ 28549 ]
            Fix Version/s 11.2 [ 28603 ]
            Fix Version/s 11.3 [ 28565 ]
            Fix Version/s 11.4 [ 29301 ]
            alice Alice Sherepa made changes -
            Affects Version/s 10.4 [ 22408 ]
            Affects Version/s 10.5 [ 23123 ]
            Affects Version/s 10.6 [ 24028 ]
            Affects Version/s 10.11 [ 27614 ]
            Affects Version/s 11.0 [ 28320 ]
            Affects Version/s 11.1 [ 28549 ]
            Affects Version/s 11.2 [ 28603 ]
            Affects Version/s 11.3 [ 28565 ]
            Affects Version/s 11.4 [ 29301 ]
            alice Alice Sherepa made changes -
            Labels regression
            alice Alice Sherepa made changes -
            alice Alice Sherepa made changes -
            Assignee Igor Babaev [ igor ]
            alice Alice Sherepa made changes -
            Status Open [ 1 ] Confirmed [ 10101 ]
            alice Alice Sherepa made changes -
            Priority Major [ 3 ] Critical [ 2 ]
            amilwaduwawara Amil Waduwawara made changes -
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s 11.0 [ 28320 ]
            Fix Version/s 11.3 [ 28565 ]
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s 10.4 [ 22408 ]
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s 11.1 [ 28549 ]
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s 11.2(EOL) [ 28603 ]
            alice Alice Sherepa made changes -
            Fix Version/s 11.7 [ 29815 ]
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s 11.7(EOL) [ 29815 ]
            monty Michael Widenius made changes -
            Assignee Igor Babaev [ igor ]
            psergei Sergei Petrunia made changes -
            Assignee Sergei Petrunia [ psergey ]
            psergei Sergei Petrunia made changes -
            Priority Critical [ 2 ] Major [ 3 ]

            People

              psergei Sergei Petrunia
              amilwaduwawara Amil Waduwawara
              Votes:
              6 Vote for this issue
              Watchers:
              5 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.