Refactor _make_subnet_dict to avoid issuing unnecessary queries

Use joined loads for attributes dns_nameservers and host_routes.

As a result, particular scenarios like restarting DHCP agent
could benefit from improved server-side performance.

Change-Id: I6470356b601e2fcf74c7e0a6df438cef7099e9fe
Closes-Bug: #1374044
This commit is contained in:
Eugene Nikanorov 2014-09-28 21:56:00 +04:00
parent 46bd7acc02
commit acfcb523b1
1 changed files with 4 additions and 2 deletions

View File

@ -184,10 +184,12 @@ class Subnet(model_base.BASEV2, HasId, HasTenant):
enable_dhcp = sa.Column(sa.Boolean())
dns_nameservers = orm.relationship(DNSNameServer,
backref='subnet',
cascade='all, delete, delete-orphan')
cascade='all, delete, delete-orphan',
lazy='joined')
routes = orm.relationship(SubnetRoute,
backref='subnet',
cascade='all, delete, delete-orphan')
cascade='all, delete, delete-orphan',
lazy='joined')
shared = sa.Column(sa.Boolean)
ipv6_ra_mode = sa.Column(sa.Enum(constants.IPV6_SLAAC,
constants.DHCPV6_STATEFUL,