Skip to content

Commit abdf926

Browse files
Revert "Use lateral join (introduced in MySQL 8.0.14) with subquery on user_statistics table in account_view for netstats (#12631)" (#12965)
This reverts commit 58916eb.
1 parent 4708121 commit abdf926

File tree

3 files changed

+35
-13
lines changed

3 files changed

+35
-13
lines changed

engine/schema/src/main/resources/META-INF/db/schema-42200to42210-cleanup.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,3 @@
1818
--;
1919
-- Schema upgrade cleanup from 4.22.0.0 to 4.22.1.0
2020
--;
21-
22-
DROP VIEW IF EXISTS `cloud`.`account_netstats_view`;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
-- cloud.account_netstats_view source
19+
20+
21+
DROP VIEW IF EXISTS `cloud`.`account_netstats_view`;
22+
23+
CREATE VIEW `cloud`.`account_netstats_view` AS
24+
select
25+
`user_statistics`.`account_id` AS `account_id`,
26+
(sum(`user_statistics`.`net_bytes_received`) + sum(`user_statistics`.`current_bytes_received`)) AS `bytesReceived`,
27+
(sum(`user_statistics`.`net_bytes_sent`) + sum(`user_statistics`.`current_bytes_sent`)) AS `bytesSent`
28+
from
29+
`user_statistics`
30+
group by
31+
`user_statistics`.`account_id`;

engine/schema/src/main/resources/META-INF/db/views/cloud.account_view.sql

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ select
3939
`data_center`.`id` AS `data_center_id`,
4040
`data_center`.`uuid` AS `data_center_uuid`,
4141
`data_center`.`name` AS `data_center_name`,
42-
`account_netstats`.`bytesReceived` AS `bytesReceived`,
43-
`account_netstats`.`bytesSent` AS `bytesSent`,
42+
`account_netstats_view`.`bytesReceived` AS `bytesReceived`,
43+
`account_netstats_view`.`bytesSent` AS `bytesSent`,
4444
`vmlimit`.`max` AS `vmLimit`,
4545
`vmcount`.`count` AS `vmTotal`,
4646
`runningvm`.`vmcount` AS `runningVms`,
@@ -89,15 +89,8 @@ from
8989
`cloud`.`domain` ON account.domain_id = domain.id
9090
left join
9191
`cloud`.`data_center` ON account.default_zone_id = data_center.id
92-
left join lateral (
93-
select
94-
coalesce(sum(`user_statistics`.`net_bytes_received` + `user_statistics`.`current_bytes_received`), 0) AS `bytesReceived`,
95-
coalesce(sum(`user_statistics`.`net_bytes_sent` + `user_statistics`.`current_bytes_sent`), 0) AS `bytesSent`
96-
from
97-
`cloud`.`user_statistics`
98-
where
99-
`user_statistics`.`account_id` = `account`.`id`
100-
) AS `account_netstats` ON TRUE
92+
left join
93+
`cloud`.`account_netstats_view` ON account.id = account_netstats_view.account_id
10194
left join
10295
`cloud`.`resource_limit` vmlimit ON account.id = vmlimit.account_id
10396
and vmlimit.type = 'user_vm' and vmlimit.tag IS NULL

0 commit comments

Comments
 (0)