commit 15ccf2ddfbf857186fc05f77a7881243c6311062
Author: Matt Riedemann <email address hidden>
Date: Thu May 23 11:14:55 2019 -0400
Avoid unnecessary joins in InstanceGroup.get_hosts
The InstanceList.get_by_filters query is joining on
info_cache, security_groups, metadata and system_metadata
because of how instance_get_all_by_filters_sort in the DB API
works if columns_to_join (expected_attrs) is None. The get_hosts
method only cares about the instance.host value of its members
so those joins are unnecessarily expensive.
This change simply passes expected_attrs=[] to get_by_filters
to avoid the joins. A follow up change can further optimize this
code by adding a new query method to just get the host values
for a list of instance uuids, so a TODO is left in place for that.
Note that a new query method would need to be remotable and thus
not something we can backport.
Reviewed: https:/ /review. opendev. org/661032 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=15ccf2ddfbf 857186fc05f77a7 881243c6311062
Committed: https:/
Submitter: Zuul
Branch: master
commit 15ccf2ddfbf8571 86fc05f77a78812 43c6311062
Author: Matt Riedemann <email address hidden>
Date: Thu May 23 11:14:55 2019 -0400
Avoid unnecessary joins in InstanceGroup. get_hosts
The InstanceList. get_by_ filters query is joining on get_all_ by_filters_ sort in the DB API
info_cache, security_groups, metadata and system_metadata
because of how instance_
works if columns_to_join (expected_attrs) is None. The get_hosts
method only cares about the instance.host value of its members
so those joins are unnecessarily expensive.
This change simply passes expected_attrs=[] to get_by_filters
to avoid the joins. A follow up change can further optimize this
code by adding a new query method to just get the host values
for a list of instance uuids, so a TODO is left in place for that.
Note that a new query method would need to be remotable and thus
not something we can backport.
Change-Id: I53d4b38d12404a 1641f667c537404 effa837a83d
Partial-Bug: #1830234