From cb2a28d82210e43a221a8fa8f2a03a7dbd6e8779 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Sun, 12 Sep 2010 17:56:28 -0700 Subject: speed up the query and make sure allocated is false --- nova/db/sqlalchemy/api.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index aa8670253..ca5e12f95 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -258,9 +258,10 @@ def fixed_ip_disassociate_all_by_timeout(_context, host, time): 'INNER JOIN networks ' 'ON fixed_ips.network_id = ' 'networks.id ' - 'WHERE host = :host) as x) ' - 'AND updated_at < :time ' - 'AND instance_id IS NOT NULL', + 'WHERE networks.host = :host ' + 'AND fixed_ip.updated_at < :time ' + 'AND fixed_ip.instance_id IS NOT NULL' + 'AND fixed_ip.allocated = 0) as x) ', {'host': host, 'time': time.isoformat()}) return result.rowcount -- cgit