Copilot commented on code in PR #12631:
URL: https://github.com/apache/cloudstack/pull/12631#discussion_r2845589494


##########
engine/schema/src/main/resources/META-INF/db/views/cloud.account_view.sql:
##########
@@ -89,8 +89,15 @@ from
     `cloud`.`domain` ON account.domain_id = domain.id
         left join
     `cloud`.`data_center` ON account.default_zone_id = data_center.id
-        left join
-    `cloud`.`account_netstats_view` ON account.id = 
account_netstats_view.account_id
+        left join lateral (
+        select
+            coalesce(sum(`user_statistics`.`net_bytes_received` + 
`user_statistics`.`current_bytes_received`), 0) AS `bytesReceived`,
+            coalesce(sum(`user_statistics`.`net_bytes_sent` + 
`user_statistics`.`current_bytes_sent`), 0) AS `bytesSent`
+        from
+            `cloud`.`user_statistics`
+        where
+            `user_statistics`.`account_id` = `account`.`id`
+    ) AS `account_netstats` ON TRUE

Review Comment:
   This PR introduces a LATERAL JOIN which requires MySQL 8.0.14 or later. This 
is a significant change that creates a new minimum MySQL version requirement 
for CloudStack. This requirement should be documented in release notes, upgrade 
documentation, and installation documentation to ensure users are aware before 
upgrading. Consider adding a migration script check or warning if the MySQL 
version is below 8.0.14.
   ```suggestion
           left join (
           select
               a.id AS `account_id`,
               coalesce(sum(`us`.`net_bytes_received` + 
`us`.`current_bytes_received`), 0) AS `bytesReceived`,
               coalesce(sum(`us`.`net_bytes_sent` + `us`.`current_bytes_sent`), 
0) AS `bytesSent`
           from
               `cloud`.`account` a
                   left join `cloud`.`user_statistics` us ON us.account_id = 
a.id
           group by a.id
       ) AS `account_netstats` ON `account_netstats`.`account_id` = 
`account`.`id`
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to