From c814991aac760e5cccbb6db1634877e7dfb8a145 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Mon, 25 Nov 2024 16:57:20 -0600 Subject: [PATCH] sqlite: more timer detail on archive Display elapsed time for lock, and query. --- src/sqlite/eventrepo.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/sqlite/eventrepo.rs b/src/sqlite/eventrepo.rs index 2090c029..c50154b2 100644 --- a/src/sqlite/eventrepo.rs +++ b/src/sqlite/eventrepo.rs @@ -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, @@ -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(()) }