[LNT] r318363 - We often lookup regression indicators by regression, index that
Chris Matthews via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 15 17:18:17 PST 2017
Author: cmatthews
Date: Wed Nov 15 17:18:17 2017
New Revision: 318363
URL: http://llvm.org/viewvc/llvm-project?rev=318363&view=rev
Log:
We often lookup regression indicators by regression, index that
The RI table is not always huge, but does get queried a lot by
regresion_id. Lets optimize that a bit.
Added:
lnt/trunk/lnt/server/db/migrations/upgrade_16_to_17.py
Modified:
lnt/trunk/lnt/server/db/testsuitedb.py
Added: lnt/trunk/lnt/server/db/migrations/upgrade_16_to_17.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/migrations/upgrade_16_to_17.py?rev=318363&view=auto
==============================================================================
--- lnt/trunk/lnt/server/db/migrations/upgrade_16_to_17.py (added)
+++ lnt/trunk/lnt/server/db/migrations/upgrade_16_to_17.py Wed Nov 15 17:18:17 2017
@@ -0,0 +1,34 @@
+"""This upgrade adds a index on the RegressionIndicator.regression_id because we often lookup
+indicators by regression.
+"""
+
+import sqlalchemy
+from sqlalchemy import Index, select
+from lnt.server.db.migrations.util import introspect_table
+from logging import getLogger
+
+log = getLogger(__name__)
+
+
+def _mk_index_on(engine, ts_name):
+ fc_table = introspect_table(engine, "{}_RegressionIndicator".format(ts_name))
+
+ fast_fc_lookup = Index('idx_fast_ri_lookup', fc_table.c.RegressionID)
+ try:
+ fast_fc_lookup.create(engine)
+ except (sqlalchemy.exc.OperationalError, sqlalchemy.exc.ProgrammingError) as e:
+ log.warning("Skipping index creation on {}, because of {}".format(fc_table.name, e.message))
+
+
+def upgrade(engine):
+ """Add an index to FieldChangeV2 for each fo the test-suites.
+ """
+
+ test_suite = introspect_table(engine, 'TestSuite')
+
+ with engine.begin() as trans:
+ db_keys = list(trans.execute(select([test_suite])))
+
+ for suite in db_keys:
+ with engine.begin() as trans:
+ _mk_index_on(trans, suite[2])
Modified: lnt/trunk/lnt/server/db/testsuitedb.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/testsuitedb.py?rev=318363&r1=318362&r2=318363&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/testsuitedb.py (original)
+++ lnt/trunk/lnt/server/db/testsuitedb.py Wed Nov 15 17:18:17 2017
@@ -680,7 +680,7 @@ class TestSuiteDB(object):
__tablename__ = db_key_name + '_RegressionIndicator'
id = Column("ID", Integer, primary_key=True)
regression_id = Column("RegressionID", Integer,
- ForeignKey(Regression.id))
+ ForeignKey(Regression.id), index=True)
field_change_id = Column("FieldChangeID", Integer,
ForeignKey(FieldChange.id))
More information about the llvm-commits
mailing list