diff --git a/CHANGELOG.md b/CHANGELOG.md index 3afbd15f1..079b1f0df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed issue where "Open in Bitbucket" and commit links for Bitbucket Server repos had an extra `/browse` in the URL. [#877](https://github.com/sourcebot-dev/sourcebot/pull/877) +- Fixed slow repo indexing scheduling query by adding database indexes. [#883](https://github.com/sourcebot-dev/sourcebot/pull/883) ### Removed - Removed the Discord and GitHub buttons from the top corner. [#874](https://github.com/sourcebot-dev/sourcebot/pull/874) diff --git a/packages/db/prisma/migrations/20260212173653_add_repo_indexing_indexes/migration.sql b/packages/db/prisma/migrations/20260212173653_add_repo_indexing_indexes/migration.sql new file mode 100644 index 000000000..7e7c751db --- /dev/null +++ b/packages/db/prisma/migrations/20260212173653_add_repo_indexing_indexes/migration.sql @@ -0,0 +1,5 @@ +-- CreateIndex +CREATE INDEX "Repo_indexedAt_idx" ON "Repo"("indexedAt"); + +-- CreateIndex +CREATE INDEX "RepoIndexingJob_repoId_type_status_idx" ON "RepoIndexingJob"("repoId", "type", "status"); diff --git a/packages/db/prisma/schema.prisma b/packages/db/prisma/schema.prisma index 423fb5960..7b16ba657 100644 --- a/packages/db/prisma/schema.prisma +++ b/packages/db/prisma/schema.prisma @@ -82,6 +82,7 @@ model Repo { @@unique([external_id, external_codeHostUrl, orgId]) @@index([orgId]) + @@index([indexedAt]) } enum RepoIndexingJobStatus { @@ -109,6 +110,8 @@ model RepoIndexingJob { repo Repo @relation(fields: [repoId], references: [id], onDelete: Cascade) repoId Int + + @@index([repoId, type, status]) } enum RepoPermissionSyncJobStatus {