summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Skladanka <jskladan@redhat.com>2012-05-21 09:02:43 (GMT)
committerJosef Skladanka <jskladan@redhat.com>2012-05-21 09:02:43 (GMT)
commitd4ae833a49f21943795ce086d6802ccb4445ad94 (patch)
tree9b2f8c42816de99c8301b410d29748c096232e74
parent0e7731f4e0a2269d26d0202c5c8b9beda754e487 (diff)
downloadResultsDB-d4ae833a49f21943795ce086d6802ccb4445ad94.zip
ResultsDB-d4ae833a49f21943795ce086d6802ccb4445ad94.tar.gz
ResultsDB-d4ae833a49f21943795ce086d6802ccb4445ad94.tar.xz
Further speed optimization
Changed the 'or' filter, which creates multiple subselects to simple IN opetator.
-rw-r--r--resultsdb/resultsdb/lib/query_api.py23
1 files changed, 5 insertions, 18 deletions
diff --git a/resultsdb/resultsdb/lib/query_api.py b/resultsdb/resultsdb/lib/query_api.py
index ae00004..f3b153b 100644
--- a/resultsdb/resultsdb/lib/query_api.py
+++ b/resultsdb/resultsdb/lib/query_api.py
@@ -68,30 +68,17 @@ class QueryApi(object):
if not isinstance(id_, (list)):
id_ = [id_]
q = q.filter(or_(*[db.Testrun.id == identif for identif in id_]))
-# q = q.filter(db.Testrun.id == id_)
if testname:
testname_alias = aliased(db.TestrunData)
- #q = q.filter(db.Testrun.testrun_data.any(key = 'testname')).filter(db.Testrun.testrun_data.any(value = testname))
- q = q.join(testname_alias).filter(and_(testname_alias.key == 'testname', testname_alias.value == testname))
+ q = q.join(testname_alias).filter(and_(testname_alias.key == 'testname', testname_alias.value == testname))
if arch:
arch_alias = aliased(db.TestrunData)
- #q = q.filter(db.Testrun.testrun_data.any(key = 'arch')).filter(db.Testrun.testrun_data.any(value = arch))
q = q.join(arch_alias).filter(and_(arch_alias.key == 'arch', arch_alias.value == arch))
if envr:
- #q = q.filter(db.Testrun.testrun_data.any(key = 'envr')).filter(db.Testrun.testrun_data.any(db.TestrunData.value.like(envr+'%')))
q = q.join(db.TestrunData).filter(and_(db.TestrunData.key == 'envr', db.TestrunData.value.like(envr+'%')))
if results:
if not isinstance(results, (list)):
results = [results]
- #if results[0] == '-':
- # all_res = map(lambda x: x['result'], self.get_results())
- # for res in results:
- # try:
- # all_res.remove(res)
- # except (ValueError):
- # pass
- # results = all_res
- #q = q.filter(or_(*[db.Testrun.result.has(result = res) for res in results]))
all_res = {}
selected_res = []
@@ -109,18 +96,18 @@ class QueryApi(object):
for res in results:
selected_res.append(all_res[res])
- # dopsat filtruj tak, ze db.TestrunData.result_id je
- q = q.filter(db.Testrun.result_id.in(map[lambda x: x['id'], selected_res))
+
+ q = q.filter(db.Testrun.result_id.in_(map(lambda x: x['id'], selected_res)))
if start:
q = q.filter(db.Testrun.start_time >= start)
if end:
q = q.filter(db.Testrun.end_time <= end)
- q = q.order_by(desc(db.Testrun.start_time))
-
count = q.count()
+ q = q.order_by(desc(db.Testrun.start_time))
+
# set the query limit
try:
limit = int(items_per_page)