internal/postgres: update only changed counts in search docs
When updating imported-by counts, only look at changed counts for
packages in search_documents.
For golang/go#47555
Trust: Jonathan Amsterdam
Run-TryBot: Jonathan Amsterdam
@@ -831,12 +831,12 @@ func (db *DB) UpdateSearchDocumentsImportedByCount(ctx context.Context) (nUpdate
if err != nil {
return 0, err
}
- // Include only changed counts.
- log.Debugf(ctx, "update-imported-by-counts: got %d counts", len(newCounts))
+ // Include only changed counts for packages that are in search_documents.
changedCounts := map[string]int{}
- for p, c := range newCounts {
- if curCounts[p] != c {
- changedCounts[p] = c
+ for p, nc := range newCounts {
+ cc, present := curCounts[p]
+ if present && cc != nc {
+ changedCounts[p] = nc
}
}
pct := 0
