Page MenuHomePhabricator

"phabricator_repository.repository_commit" table has poor keys for naive iteration
Closed, ResolvedPublic

Description

See PHI1540. In at least two workflows (bin/repository rebuild-identities and bin/audit delete) we iterate over all commits in a repository.

This currently resolves into a ... WHERE repositoryID = X id < Y ORDER BY id DESC query, but there is no <repositoryID, id> key on the table, and we can end up with a less-than-ideal query. There are two nearly-suitable keys (<repositoryID, epoch, [id]> and <repositoryID, importStatus, [id]>).

Both workflows can likely be made better by adding an additional epoch ordering to the query, so the full <repositoryID, epoch, [id]> key can be used.