Add an index on the logs_archived boolean on a RepositoryBuild
Addresses the slow query: ``` SELECT `candidates` . `id` FROM ( SELECT `t1` . `id` FROM `repositorybuild` AS `t1` WHERE ( ( ( `t1` . `phase` IN (...) ) OR ( `t1` . `started` < ? ) ) AND ( `t1` . `logs_archived` = ? ) ) LIMIT ? ) AS `candidates` ORDER BY `Rand` ( ) LIMIT ? OFFSET ? ``` While the cardinality on `logs_archived` will be low, it should also only be in the `false` state for a very small number of records, so it should make this query very, very fast.
This commit is contained in:
parent
c4f7b28dc6
commit
f4a1646a8b
2 changed files with 25 additions and 1 deletions
|
@ -997,7 +997,7 @@ class RepositoryBuild(BaseModel):
|
|||
trigger = ForeignKeyField(RepositoryBuildTrigger, null=True)
|
||||
pull_robot = QuayUserField(null=True, backref='buildpullrobot', allows_robots=True,
|
||||
robot_null_delete=True)
|
||||
logs_archived = BooleanField(default=False)
|
||||
logs_archived = BooleanField(default=False, index=True)
|
||||
queue_id = CharField(null=True, index=True)
|
||||
|
||||
class Meta:
|
||||
|
|
Reference in a new issue