mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
CLOUDSTACK-9340: General DB Optimization
This commit is contained in:
parent
4d57ec04ac
commit
8b6e6185f5
@ -18,3 +18,68 @@
|
|||||||
--;
|
--;
|
||||||
-- Schema cleanup from 4.8.1 to 4.9.0;
|
-- Schema cleanup from 4.8.1 to 4.9.0;
|
||||||
--;
|
--;
|
||||||
|
|
||||||
|
-- Added in CLOUDSTACK-9340: General DB optimization, 4 cases:
|
||||||
|
|
||||||
|
----- 1) Incorrect PRIMARY key
|
||||||
|
ALTER TABLE `cloud`.`ovs_tunnel_network`
|
||||||
|
DROP PRIMARY KEY,
|
||||||
|
ADD PRIMARY KEY (`id`),
|
||||||
|
DROP INDEX `id` ,
|
||||||
|
ADD UNIQUE INDEX `i_to_from_network_id` (`to` ASC, `from` ASC, `network_id` ASC);
|
||||||
|
|
||||||
|
----- 2) Duplicate PRIMARY KEY
|
||||||
|
ALTER TABLE `cloud`.`user_vm` DROP INDEX `id_2` ,DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`domain_router` DROP INDEX `id_2` ,DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`vm_instance` DROP INDEX `id_2` ,DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`account_vlan_map` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`account_vnet_map` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`baremetal_rct` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`cluster` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`conditions` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`counter` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`data_center` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`dc_storage_network_ip_range` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`dedicated_resources` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`host_pod_ref` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`iam_group` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`iam_policy` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`iam_policy_permission` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`image_store_details` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`instance_group` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`netapp_lun` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`netapp_pool` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`netapp_volume` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`network_acl_item_cidrs` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`network_offerings` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`nic_secondary_ips` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`nics` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`op_ha_work` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`op_host` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`op_host_transfer` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`op_networks` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`op_nwgrp_work` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`op_vm_ruleset_log` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`op_vpc_distributed_router_sequence_no` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`pod_vlan_map` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`portable_ip_address` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`portable_ip_range` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`region` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`remote_access_vpn` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`snapshot_details` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`snapshots` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`storage_pool` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`storage_pool_details` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`storage_pool_work` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`user_ip_address` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`user_ipv6_address` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`user_statistics` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`version` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`vlan` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`vm_disk_statistics` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`vm_snapshot_details` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`vm_work_job` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`vpc_gateways` DROP INDEX `id` ;
|
||||||
|
ALTER TABLE `cloud`.`vpn_users` DROP INDEX `id` ;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -413,3 +413,26 @@ VIEW `user_vm_view` AS
|
|||||||
|
|
||||||
-- Add cluster.storage.operations.exclude property
|
-- Add cluster.storage.operations.exclude property
|
||||||
INSERT INTO `cloud`.`configuration` (`category`, `instance`, `component`, `name`, `description`, `default_value`, `updated`, `scope`, `is_dynamic`) VALUES ('Advanced', 'DEFAULT', 'CapacityManager', 'cluster.storage.operations.exclude', 'Exclude cluster from storage operations', 'false', now(), 'Cluster', '1');
|
INSERT INTO `cloud`.`configuration` (`category`, `instance`, `component`, `name`, `description`, `default_value`, `updated`, `scope`, `is_dynamic`) VALUES ('Advanced', 'DEFAULT', 'CapacityManager', 'cluster.storage.operations.exclude', 'Exclude cluster from storage operations', 'false', now(), 'Cluster', '1');
|
||||||
|
|
||||||
|
----- 3) Missing indexes (Add indexes to avoid full table scans)
|
||||||
|
ALTER TABLE `cloud`.`op_it_work` ADD INDEX `i_type_and_updated` (`type` ASC, `updated_at` ASC);
|
||||||
|
ALTER TABLE `cloud`.`vm_root_disk_tags` ADD INDEX `i_vm_id` (`vm_id` ASC);
|
||||||
|
ALTER TABLE `cloud`.`vm_compute_tags` ADD INDEX `i_vm_id` (`vm_id` ASC);
|
||||||
|
ALTER TABLE `cloud`.`vm_network_map` ADD INDEX `i_vm_id` (`vm_id` ASC);
|
||||||
|
ALTER TABLE `cloud`.`ssh_keypairs` ADD INDEX `i_public_key` (`public_key` (64) ASC);
|
||||||
|
ALTER TABLE `cloud`.`user_vm_details` ADD INDEX `i_name_vm_id` (`vm_id` ASC, `name` ASC);
|
||||||
|
ALTER TABLE `cloud`.`instance_group` ADD INDEX `i_name` (`name` ASC);
|
||||||
|
|
||||||
|
----- 4) Some views query (Change view to improve account retrieval speed)
|
||||||
|
CREATE OR REPLACE
|
||||||
|
VIEW `account_vmstats_view` AS
|
||||||
|
SELECT
|
||||||
|
`vm_instance`.`account_id` AS `account_id`,
|
||||||
|
`vm_instance`.`state` AS `state`,
|
||||||
|
COUNT(0) AS `vmcount`
|
||||||
|
FROM
|
||||||
|
`vm_instance`
|
||||||
|
WHERE
|
||||||
|
(`vm_instance`.`vm_type` = 'User' and `vm_instance`.`removed` is NULL)
|
||||||
|
GROUP BY `vm_instance`.`account_id` , `vm_instance`.`state`;
|
||||||
|
-- End CLOUDSTACK-9340
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user