summaryrefslogtreecommitdiffstats
path: root/nova/db/sqlalchemy/models.py
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2013-01-30 16:23:04 -0800
committerVishvananda Ishaya <vishvananda@gmail.com>2013-02-02 08:47:45 -0800
commit655ae2e9394dd91e70a52cc504dfab8f4431e2fa (patch)
treee5ed8f65f2c288b5a4ea0b3e97e24d398a7eaf8a /nova/db/sqlalchemy/models.py
parent922f81c18bfbfd3ca8a0b5b1edf59723f7d366af (diff)
downloadnova-655ae2e9394dd91e70a52cc504dfab8f4431e2fa.tar.gz
nova-655ae2e9394dd91e70a52cc504dfab8f4431e2fa.tar.xz
nova-655ae2e9394dd91e70a52cc504dfab8f4431e2fa.zip
Optimize floating ip list to make one db query
Currently the floating ip code will make 2 db queries for every single associated floating ip when list is called. This adds a couple of joins in the db layer to avoid having to make so many calls. This dramatically improves floating-ip-list. On a simple one node test the time dropped from 2.35 seconds down to 0.5 seconds for a list with 10 associated floating ips. Part of blueprint optimize-nova-network Change-Id: I0571013393b2dbad42c15e690c7783d5ceecaeb2
Diffstat (limited to 'nova/db/sqlalchemy/models.py')
-rw-r--r--nova/db/sqlalchemy/models.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index fd8348678..b4c680ac0 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -724,7 +724,14 @@ class FixedIp(BASE, NovaBase):
foreign_keys=network_id,
primaryjoin='and_('
'FixedIp.network_id == Network.id,'
- 'FixedIp.deleted == 0)')
+ 'FixedIp.deleted == 0,'
+ 'Network.deleted == 0)')
+ instance = relationship(Instance,
+ foreign_keys=instance_uuid,
+ primaryjoin='and_('
+ 'FixedIp.instance_uuid == Instance.uuid,'
+ 'FixedIp.deleted == 0,'
+ 'Instance.deleted == 0)')
class FloatingIp(BASE, NovaBase):
@@ -738,6 +745,13 @@ class FloatingIp(BASE, NovaBase):
auto_assigned = Column(Boolean, default=False, nullable=False)
pool = Column(String(255))
interface = Column(String(255))
+ fixed_ip = relationship(FixedIp,
+ backref=backref('floating_ips'),
+ foreign_keys=fixed_ip_id,
+ primaryjoin='and_('
+ 'FloatingIp.fixed_ip_id == FixedIp.id,'
+ 'FloatingIp.deleted == 0,'
+ 'FixedIp.deleted == 0)')
class DNSDomain(BASE, NovaBase):