Skip to content

Commit

Permalink
timings
Browse files Browse the repository at this point in the history
  • Loading branch information
jh-bate committed Dec 20, 2023
1 parent 7d34f3b commit e992757
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ func (m *Migration) blockUntilDBReady() error {
}

func (m *Migration) fetchAndUpdateBatch() bool {
start := time.Now()
fetchAndUpdateStart := time.Now()

selector := bson.M{
"_deduplicator": bson.M{"$exists": false},
Expand All @@ -383,6 +383,9 @@ func (m *Migration) fetchAndUpdateBatch() bool {
m.updates = []mongo.WriteModel{}

if dataC := m.getDataCollection(); dataC != nil {

fetchStart := time.Now()

dDataCursor, err := dataC.Find(m.ctx, selector,
&options.FindOptions{
Limit: &m.config.readBatchSize,
Expand All @@ -395,6 +398,9 @@ func (m *Migration) fetchAndUpdateBatch() bool {
}

defer dDataCursor.Close(m.ctx)

log.Printf("fetch took %s", time.Since(fetchStart))
updateStart := time.Now()
for dDataCursor.Next(m.ctx) {
var dDataResult bson.M
if err = dDataCursor.Decode(&dDataResult); err != nil {
Expand All @@ -413,7 +419,9 @@ func (m *Migration) fetchAndUpdateBatch() bool {
m.updates = append(m.updates, updateOp)
m.lastUpdatedId = datumID
}
log.Printf("selector took %s", time.Since(start))

log.Printf("update took %s", time.Since(updateStart))
log.Printf("fetch and update took %s", time.Since(fetchAndUpdateStart))
return len(m.updates) > 0
}
return false
Expand Down
1 change: 0 additions & 1 deletion migrations/20231128_jellyfish_migration/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,5 @@ func GetDatumUpdates(bsonData bson.M) (string, bson.M, error) {
if rename != nil {
updates["$rename"] = rename
}

return datumID, updates, nil
}

0 comments on commit e992757

Please sign in to comment.