Force get_all to only make one DB call
Previously our database repository "get_all" query would lazy load child objects. This means for each record returned, sqlalchemy will make multiple additional calls to the database when we build the data model. This patch changes the query to do a joined load so that all of the required information for the data model is pulled over at one time. This will increase the peak memory usage on the api server during the API call, but it should still be at a reasonable level. Change-Id: If83c5e8cd8d13d31ad0c5130e1b8b1a1209abadb
This commit is contained in:
parent
e37c0c7197
commit
77068905e1
@ -25,6 +25,7 @@ from oslo_db import exception as db_exception
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import uuidutils
|
||||
from sqlalchemy.orm import joinedload
|
||||
|
||||
from octavia.common import constants as consts
|
||||
from octavia.common import data_models
|
||||
@ -113,6 +114,8 @@ class BaseRepository(object):
|
||||
"""
|
||||
deleted = filters.pop('show_deleted', True)
|
||||
query = session.query(self.model_class).filter_by(**filters)
|
||||
# Only make one trip to the database
|
||||
query = query.options(joinedload('*'))
|
||||
|
||||
if not deleted:
|
||||
query = query.filter(
|
||||
|
Loading…
Reference in New Issue
Block a user