summaryrefslogtreecommitdiffstats
path: root/nova/db/sqlalchemy/models.py
diff options
context:
space:
mode:
authorJoe Gordon <jogo@cloudscaling.com>2013-02-27 20:59:08 +0000
committerJoe Gordon <jogo@cloudscaling.com>2013-02-28 04:01:24 +0000
commitce23d6c1d679355bafede816bca39ea1eb24073c (patch)
tree60409d750269859f1cbc02ef870b72ad7e5c97ae /nova/db/sqlalchemy/models.py
parentf86f9a8cb508da22bf02ac602710bacd8e2c1ff2 (diff)
downloadnova-ce23d6c1d679355bafede816bca39ea1eb24073c.tar.gz
nova-ce23d6c1d679355bafede816bca39ea1eb24073c.tar.xz
nova-ce23d6c1d679355bafede816bca39ea1eb24073c.zip
Shrink size of aggregate_metadata_get_by_host sql query
* Remove unnecessary secondary joins in Aggregate model. * Remove unnecessary backrefs (only needed to create bidirectional relationship) aggregate_metadata_get_by_host goes from 6 JOINS down to two JOINS. Fix bug 1133495 Change-Id: I72966fa205973ec638816b07bfdcd54f1102feb5
Diffstat (limited to 'nova/db/sqlalchemy/models.py')
-rw-r--r--nova/db/sqlalchemy/models.py23
1 files changed, 5 insertions, 18 deletions
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index 95456bf98..f52d82982 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -841,29 +841,16 @@ class Aggregate(BASE, NovaBase):
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String(255))
_hosts = relationship(AggregateHost,
- lazy="joined",
- secondary="aggregate_hosts",
primaryjoin='and_('
- 'Aggregate.id == AggregateHost.aggregate_id,'
- 'AggregateHost.deleted == 0,'
- 'Aggregate.deleted == 0)',
- secondaryjoin='and_('
- 'AggregateHost.aggregate_id == Aggregate.id, '
- 'AggregateHost.deleted == 0,'
- 'Aggregate.deleted == 0)',
- backref='aggregates')
+ 'Aggregate.id == AggregateHost.aggregate_id,'
+ 'AggregateHost.deleted == 0,'
+ 'Aggregate.deleted == 0)')
_metadata = relationship(AggregateMetadata,
- secondary="aggregate_metadata",
- primaryjoin='and_('
+ primaryjoin='and_('
'Aggregate.id == AggregateMetadata.aggregate_id,'
'AggregateMetadata.deleted == 0,'
- 'Aggregate.deleted == 0)',
- secondaryjoin='and_('
- 'AggregateMetadata.aggregate_id == Aggregate.id, '
- 'AggregateMetadata.deleted == 0,'
- 'Aggregate.deleted == 0)',
- backref='aggregates')
+ 'Aggregate.deleted == 0)')
def _extra_keys(self):
return ['hosts', 'metadetails', 'availability_zone']