Skip to content

Commit

Permalink
sqlite: more timer detail on archive
Browse files Browse the repository at this point in the history
Display elapsed time for lock, and query.
  • Loading branch information
jasonish committed Nov 25, 2024
1 parent e737f7e commit c814991
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/sqlite/eventrepo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ impl SqliteEventRepo {
debug!("Archiving alert group: {:?}", alert_group);

let action = HistoryEntryBuilder::new_archive().build();
let now = Instant::now();
let sql = "
UPDATE events
SET archived = 1,
Expand Down Expand Up @@ -210,10 +209,17 @@ impl SqliteEventRepo {
info!("sql={}", &sql);
}

let start = Instant::now();
let mut conn = self.writer.lock().await;
let write_lock_elapsed = start.elapsed();
let x = sqlx::query_with(&sql, args).execute(&mut *conn).await?;
let query_elapsed = start.elapsed();
let n = x.rows_affected();
debug!("Archived {n} alerts in {} ms", now.elapsed().as_millis());
debug!(
"Archived {n} alerts in {} ms (write-lock wait: {})",
query_elapsed.as_millis(),
write_lock_elapsed.as_millis()
);

Ok(())
}
Expand Down

0 comments on commit c814991

Please sign in to comment.