summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Callaghan <dcallagh@redhat.com>2014-07-02 12:15:08 +1000
committerDan Callaghan <dcallagh@redhat.com>2014-07-02 12:17:45 +1000
commit49e16e2fc348f20c062b330fa53778d0fdc9fb7b (patch)
tree43455f99ec11097549a4b6fd69e12ac8583e4fec
parentc27a152f877c3c97a97e9035fe7d88c534270114 (diff)
fix inefficient queries from system page activity tab
There are two changes here: * use system_activity.id in the ORDER BY clause, instead of activity.created or activity.id (this allows MySQL to avoid a temp table and filesort) * pass a SQLAlchemy query through to the activity grid, so that TG @paginate can do its thing (this avoids fetching the entire activity result set, instead the query will have a suitable LIMIT applied) Bug: 1097094 Change-Id: I6732044f3cb4b440a23190eed717d2fc65c043b8
-rw-r--r--Server/bkr/server/controllers.py2
-rw-r--r--Server/bkr/server/model/inventory.py4
2 files changed, 3 insertions, 3 deletions
diff --git a/Server/bkr/server/controllers.py b/Server/bkr/server/controllers.py
index 1547faf..b490ee9 100644
--- a/Server/bkr/server/controllers.py
+++ b/Server/bkr/server/controllers.py
@@ -861,7 +861,7 @@ class Root(RPCRoot):
if 'activities_found' in histories_return:
historical_data = histories_return['activities_found']
else:
- historical_data = system.activity[:150]
+ historical_data = system.dyn_activity
if readonly:
attrs = dict(readonly = 'True')
diff --git a/Server/bkr/server/model/inventory.py b/Server/bkr/server/model/inventory.py
index 595c810..627279f 100644
--- a/Server/bkr/server/model/inventory.py
+++ b/Server/bkr/server/model/inventory.py
@@ -285,9 +285,9 @@ class System(DeclarativeMappedObject, ActivityMixin):
key_values_string = relationship('Key_Value_String', backref='system',
cascade='all, delete, delete-orphan')
activity = relationship(SystemActivity, backref='object', cascade='all, delete',
- order_by=[SystemActivity.created.desc(), SystemActivity.id.desc()])
+ order_by=[SystemActivity.__table__.c.id.desc()])
dyn_activity = dynamic_loader(SystemActivity,
- order_by=[SystemActivity.created.desc(), SystemActivity.id.desc()])
+ order_by=[SystemActivity.__table__.c.id.desc()])
command_queue = relationship(CommandActivity, backref='object',
cascade='all, delete, delete-orphan',
order_by=[CommandActivity.created.desc(), CommandActivity.id.desc()])