-
Type:
Task
-
Status: In Review (View Workflow)
-
Priority:
Normal
-
Resolution: Unresolved
-
Component/s: spt_operational_database
-
Epic Link:
A lot of the tables in our database are defined such that they have a primary key and a unique constraint on the same columns, which is redundant. This mostly comes from the models in spt_operational_database, which define things like Column(Integer, primary_key=True, unique=True, ...) where both are set to True .
Both primary keys and unique indexes force a check on insert and force an additional write to the database. The check has to scan the entire btree, which is does twice, once for the PK and once for the unique index.
For mcs_data and cobra_target we have over 150 million rows so this double-checking of indexes when doing an insert is likely affecting performance.
We should be able to drop the unique constraints without issue.