sapcc / manila

Shared filesystem management project for OpenStack.
http://openstack.org
Apache License 2.0
0 stars 2 forks source link

modify lazy loading for ShareInstance model #202

Closed chuan137 closed 1 week ago

chuan137 commented 3 weeks ago

The ShareInstance model has relationships with AvailabilityZone and ShareType models. These relationships are loaded lazily by subquery. This emits sql queries for availability zone and share type with subquery for all share instances, which is not efficient as the share instance table grows. This change modifies the relationships to load the availability zone and share type with selectin load, which will load all items from the availability zone and share type tables in a single query. It's acceptable because they are pretty small tables.

Reference for selectin loading: link

Change-Id: I0525b8cff6616e4e6f290de50dcdd50e1b7435d8

chuan137 commented 3 weeks ago

modified another lazy loading, for relationship between share and share instance. It's frequently used in the share/details API. This should give noticeable performance improvement.