Liran Zelkha has uploaded a new change for review.

Change subject: core: getdisksvmguid hit the perf due to 
all_disks_including_snapshots view
......................................................................

core: getdisksvmguid hit the perf due to all_disks_including_snapshots view

Add index
Replace UNION with UNION ALL, which doing group by of the images
to avoid duplicates

Change-Id: I076e804cab601f3873cf2fdccba77abe42da60d3
Bug-Url: https://bugzilla.redhat.com/1141543
Signed-off-by: lzel...@redhat.com <lzel...@redhat.com>
---
M packaging/dbscripts/create_views.sql
A packaging/dbscripts/upgrade/03_06_0660_add_index_image_storage_domain_map.sql
2 files changed, 36 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/76/36376/1

diff --git a/packaging/dbscripts/create_views.sql 
b/packaging/dbscripts/create_views.sql
index adfd379..2532d62 100644
--- a/packaging/dbscripts/create_views.sql
+++ b/packaging/dbscripts/create_views.sql
@@ -221,7 +221,41 @@
            null AS device_size
     FROM images_storage_domain_view
     INNER JOIN storage_for_image_view ON images_storage_domain_view.image_guid 
= storage_for_image_view.image_id
-    UNION
+    GROUP BY storage_for_image_view.storage_id,
+           storage_for_image_view.storage_path,
+           storage_for_image_view.storage_name,
+           storage_for_image_view.storage_type,
+           storage_pool_id,
+           image_guid, -- Image fields
+           creation_date,
+           actual_size,
+           read_rate,
+           write_rate,
+           read_latency_seconds,
+           write_latency_seconds,
+           flush_latency_seconds,
+           size,
+           it_guid,
+           imageStatus,
+           lastModified,
+           volume_type,
+           volume_format,
+           image_group_id,
+           description, -- Snapshot fields
+           ParentId,
+           app_list,
+           vm_snapshot_id,
+           active,
+           entity_type,
+           number_of_vms,
+           vm_names,
+           storage_for_image_view.quota_id,
+           storage_for_image_view.quota_name,
+           quota_enforcement_type,
+           ovf_store,
+           storage_for_image_view.disk_profile_id,
+           storage_for_image_view.disk_profile_name
+    UNION ALL
     SELECT 1 AS disk_storage_type,
            null AS storage_id, -- Storage domain fields
            null AS storage_path,
@@ -270,7 +304,6 @@
     LEFT JOIN vms_for_disk_view on vms_for_disk_view.device_id = dlm.disk_id
 ) AS storage_impl
 JOIN base_disks bd ON bd.disk_id = storage_impl.image_group_id;
-
 
 CREATE OR REPLACE VIEW all_disks
 AS
diff --git 
a/packaging/dbscripts/upgrade/03_06_0660_add_index_image_storage_domain_map.sql 
b/packaging/dbscripts/upgrade/03_06_0660_add_index_image_storage_domain_map.sql
new file mode 100644
index 0000000..cfc01a8
--- /dev/null
+++ 
b/packaging/dbscripts/upgrade/03_06_0660_add_index_image_storage_domain_map.sql
@@ -0,0 +1 @@
+select fn_db_create_index('IDX_image_storage_domain_map_image_id', 
'image_storage_domain_map', 'image_id', '');


-- 
To view, visit http://gerrit.ovirt.org/36376
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I076e804cab601f3873cf2fdccba77abe42da60d3
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Liran Zelkha <lzel...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to