nova/nova/tests/unit/db
melanie witt 63d2e62c3a Use subqueryload() instead of joinedload() for (system_)metadata
Currently, when we "get" a single instance from the database and we
load metadata and system_metadata, we do so using a joinedload() which
does JOINs with the respective tables. Because of the one-to-many
relationship between an instance and (system_)metadata records, doing
the database query this way can result in a large number of additional
rows being returned unnecessarily and cause a large data transfer.

This is similar to the problem addressed by change
I0610fb16ccce2ee95c318589c8abcc30613a3fe9 which added separate queries
for (system_)metadata when we "get" multiple instances. We don't,
however, reuse the same code for this change because
_instances_fill_metadata converts the instance database object to a
dict, and some callers of _instance_get_by_uuid need to be able to
access an instance database object attached to the session (example:
instance_update_and_get_original).

By using subqueryload() [1], we can perform the additional queries for
(system_)metadata to solve the problem with a similar approach.

Closes-Bug: #1799298

[1] https://docs.sqlalchemy.org/en/13/orm/loading_relationships.html#subquery-eager-loading

Change-Id: I5c071f70f669966e9807b38e99077c1cae5b4606
(cherry picked from commit e728fe668a)
2021-01-13 12:43:15 +00:00
..
__init__.py move all tests to nova/tests/unit 2014-11-12 15:31:08 -05:00
fakes.py nova-net: Remove unused 'stub_out_db_network_api' 2019-12-12 10:21:00 +00:00
test_db_api.py Use subqueryload() instead of joinedload() for (system_)metadata 2021-01-13 12:43:15 +00:00
test_migration_utils.py Remove oslo_db.sqlalchemy.compat reference 2020-03-04 16:59:48 +00:00
test_migrations.py Add placeholder migrations for Ussuri backports 2020-04-24 09:26:42 +09:00
test_models.py Test that new tables don't use soft deletes 2016-02-04 09:21:31 -05:00
test_sqlalchemy_migration.py Fix configure() called after DatabaseAtVersion fixture 2020-05-22 17:45:14 +01:00