From: Aaron Rosen Date: Wed, 26 Mar 2014 20:52:05 +0000 (-0700) Subject: Subnets should be set as lazy='join' X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=cbeda85fe5284d2ec0ba39976cdf6ffcdfbdd84a;p=openstack-build%2Fneutron-build.git Subnets should be set as lazy='join' Currently if one does a net-list tons of queries are issued against the database as the default query mode is 'select' which performs a query when the field is actually accessed. In this patch I change the the mode to 'joined' so subnets are loaded as the networks are loaded. Usually, there are only 1 or 2 subnets on a network so loading this data shouldn't hurt. This patch in my setup with 5000 networks reduces the net-list call from 27 seconds to 7! Woot Woot :) Change-Id: I10eec4d79b522dfd685d3d2aa93a8d643104bba7 Closes-bug: 1298053 --- diff --git a/neutron/db/models_v2.py b/neutron/db/models_v2.py index 2c77ec67e..718195f34 100644 --- a/neutron/db/models_v2.py +++ b/neutron/db/models_v2.py @@ -199,7 +199,8 @@ class Network(model_base.BASEV2, HasId, HasTenant): name = sa.Column(sa.String(255)) ports = orm.relationship(Port, backref='networks') - subnets = orm.relationship(Subnet, backref='networks') + subnets = orm.relationship(Subnet, backref='networks', + lazy="joined") status = sa.Column(sa.String(16)) admin_state_up = sa.Column(sa.Boolean) shared = sa.Column(sa.Boolean)