Comment 5 for bug 1830234

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/stein)

Reviewed: https://review.opendev.org/664271
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=74e66fe8d4353be95868a68d21d882020cb40f4b
Submitter: Zuul
Branch: stable/stein

commit 74e66fe8d4353be95868a68d21d882020cb40f4b
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.

    Change-Id: I53d4b38d12404a1641f667c537404effa837a83d
    Partial-Bug: #1830234
    (cherry picked from commit 15ccf2ddfbf857186fc05f77a7881243c6311062)